Fix up server timeout code
This commit is contained in:
parent
210938644a
commit
3ea54fdfcd
@ -11,6 +11,7 @@ import net.frozenorb.apiv3.APIv3;
|
||||
import net.frozenorb.apiv3.serialization.gson.ExcludeFromReplies;
|
||||
import net.frozenorb.apiv3.unsorted.MongoToVoidMongoCallback;
|
||||
import net.frozenorb.apiv3.util.SyncUtils;
|
||||
import net.frozenorb.apiv3.util.TimeUtils;
|
||||
import org.bson.Document;
|
||||
|
||||
import java.time.Instant;
|
||||
@ -64,27 +65,25 @@ public final class Server {
|
||||
}));
|
||||
}
|
||||
|
||||
// TODO: This code isn't multi-instance safe AND will send more
|
||||
// db requests than needed.
|
||||
private static void updateTimedOutServers() {
|
||||
/*for (Server server : serverCache) {
|
||||
for (Server server : serverCache) {
|
||||
int lastUpdatedAgo = TimeUtils.getSecondsBetween(server.getLastUpdatedAt(), Instant.now());
|
||||
|
||||
if (lastUpdatedAgo < TimeUnit.SECONDS.toSeconds(30)) {
|
||||
if (lastUpdatedAgo < 60 || lastUpdatedAgo > 30 * 5) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (UUID online : server.getPlayers()) {
|
||||
User.findById(online, (user, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
User.findById(online, (user, findUserError) -> {
|
||||
if (findUserError != null) {
|
||||
findUserError.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
if (user.leftServer(server)) {
|
||||
user.save((ignored, error2) -> {
|
||||
if (error2 != null) {
|
||||
error2.printStackTrace();
|
||||
user.save((ignored, saveUserError) -> {
|
||||
if (saveUserError != null) {
|
||||
saveUserError.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -97,7 +96,7 @@ public final class Server {
|
||||
error.printStackTrace();
|
||||
}
|
||||
});
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
private Server() {} // For Jackson
|
||||
|
Loading…
Reference in New Issue
Block a user