2018-12-16 17:27:44 +03:00
|
|
|
package InnaIrcBot;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
public class ReconnectControl {
|
2020-10-20 03:37:20 +03:00
|
|
|
private static final HashMap<String, Boolean> serversList = new HashMap<>();
|
2018-12-16 17:27:44 +03:00
|
|
|
public static synchronized void register(String serverName){
|
|
|
|
serversList.put(serverName, true);
|
|
|
|
}
|
|
|
|
public static synchronized void update(String serverName, boolean needReconnect){
|
|
|
|
serversList.replace(serverName, needReconnect);
|
|
|
|
}
|
|
|
|
|
2020-10-20 03:37:20 +03:00
|
|
|
public static synchronized void notify(String serverName) {
|
|
|
|
if (serversList.get(serverName) == null || ! serversList.get(serverName)){
|
|
|
|
serversList.remove(serverName);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
System.out.println("DEBUG: Thread "+serverName+" removed from observable list after unexpected finish.\n\t");
|
|
|
|
ConnectionsBuilder.getConnections().startNewConnection(serverName);
|
|
|
|
}
|
2018-12-16 17:27:44 +03:00
|
|
|
}
|