forked from j62/ctbrec
1
0
Fork 0

Try to log in on startup

Maybe we have to change this in the future so that the server logs in
on a regular basis.
This commit is contained in:
0xboobface 2020-05-23 13:47:57 +02:00
parent 3958a7b5f1
commit 5e46933905
1 changed files with 16 additions and 0 deletions

View File

@ -95,6 +95,7 @@ public class HttpServer {
for (Site site : sites) {
if (site.isEnabled()) {
site.init();
safeLogin(site);
}
}
onlineMonitor = new OnlineMonitor(recorder);
@ -102,6 +103,21 @@ public class HttpServer {
startHttpServer();
}
private void safeLogin(Site site) {
if (site.credentialsAvailable()) {
try {
boolean success = site.login();
if (success) {
LOG.info("Successfully logged in to {}", site.getName());
} else {
throw new RuntimeException("Login returned false");
}
} catch (Exception e) {
LOG.info("Login to {} failed", site.getName());
}
}
}
private void createSites() {
sites.add(new BongaCams());
sites.add(new Cam4());