Zond:fix: грамонтное отключение от ASys
This commit is contained in:
@@ -64,6 +64,7 @@ public class ZondCommandHandler implements CommandHandler {
|
||||
} else if (line.equalsIgnoreCase("connect")) {
|
||||
Connector.getInstance().startReconnect();
|
||||
} else if (line.equalsIgnoreCase("disconnect")) {
|
||||
Shell.getInstance().getOutput().println("Disconnect");
|
||||
Connector.getInstance().shutdown();
|
||||
} else if (line.equalsIgnoreCase("reload")) {
|
||||
Shell.getInstance().getOutput().println("Reload config");
|
||||
|
||||
@@ -33,9 +33,12 @@ public class Client {
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (isConnected()) {
|
||||
channelFuture.channel().close();
|
||||
channelFuture = null;
|
||||
group.shutdownGracefully();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
return (channelFuture != null && channelFuture.isSuccess());
|
||||
|
||||
@@ -23,7 +23,8 @@ public class Connector {
|
||||
}
|
||||
|
||||
public void startReconnect() {
|
||||
if (connectTicker != null && connectTicker.isActive()) return;
|
||||
if ((connectTicker != null && connectTicker.isActive()) ||
|
||||
(client != null && client.isConnected())) return;
|
||||
client = new Client();
|
||||
connectTicker = new TaskTicker().setStepTimeMs(5000L);
|
||||
connectTicker.setTask(() -> {
|
||||
|
||||
Reference in New Issue
Block a user