mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
LaunchServer code optimizations.
This commit is contained in:
parent
3a8f4dcadc
commit
f56c26ad2b
2 changed files with 2 additions and 4 deletions
|
@ -51,7 +51,6 @@ public ProguardConf(LaunchServer srv) {
|
|||
private void genConfig(boolean force) throws IOException {
|
||||
if (IOHelper.exists(config) && !force) return;
|
||||
Files.deleteIfExists(config);
|
||||
config.toFile().createNewFile();
|
||||
try (OutputStream out = IOHelper.newOutput(config); InputStream in = IOHelper.newInput(IOHelper.getResourceURL("ru/gravit/launchserver/defaults/proguard.cfg"))) {
|
||||
IOHelper.transfer(in, out);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
public class SessionManager implements NeedGarbageCollection {
|
||||
|
||||
public static final long SESSION_TIMEOUT = 10 * 60 * 1000; // 10 минут
|
||||
public static final boolean NON_GARBAGE_SERVER = true;
|
||||
public static final boolean GARBAGE_SERVER = Boolean.parseBoolean(System.getProperty("launcher.garbage.sessions", "false"));
|
||||
private HashSet<Client> clientSet = new HashSet<>(128);
|
||||
|
||||
|
||||
|
@ -19,10 +19,9 @@ public boolean addClient(Client client) {
|
|||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void garbageCollection() {
|
||||
long time = System.currentTimeMillis();
|
||||
clientSet.removeIf(c -> (c.timestamp + SESSION_TIMEOUT < time) && ((c.type == Client.Type.USER) || ((c.type == Client.Type.SERVER) && !NON_GARBAGE_SERVER)));
|
||||
clientSet.removeIf(c -> (c.timestamp + SESSION_TIMEOUT < time) && (c.type == Client.Type.USER) && GARBAGE_SERVER);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue