Archived
0

Zond:fix: грамонтное отключение от ASys

This commit is contained in:
2017-06-17 14:29:46 +03:00
parent 4c410cb7e7
commit 2100f7a805
3 changed files with 8 additions and 3 deletions

View File

@@ -64,6 +64,7 @@ public class ZondCommandHandler implements CommandHandler {
} else if (line.equalsIgnoreCase("connect")) { } else if (line.equalsIgnoreCase("connect")) {
Connector.getInstance().startReconnect(); Connector.getInstance().startReconnect();
} else if (line.equalsIgnoreCase("disconnect")) { } else if (line.equalsIgnoreCase("disconnect")) {
Shell.getInstance().getOutput().println("Disconnect");
Connector.getInstance().shutdown(); Connector.getInstance().shutdown();
} else if (line.equalsIgnoreCase("reload")) { } else if (line.equalsIgnoreCase("reload")) {
Shell.getInstance().getOutput().println("Reload config"); Shell.getInstance().getOutput().println("Reload config");

View File

@@ -33,9 +33,12 @@ public class Client {
} }
public void disconnect() { public void disconnect() {
if (isConnected()) {
channelFuture.channel().close(); channelFuture.channel().close();
channelFuture = null;
group.shutdownGracefully(); group.shutdownGracefully();
} }
}
public boolean isConnected() { public boolean isConnected() {
return (channelFuture != null && channelFuture.isSuccess()); return (channelFuture != null && channelFuture.isSuccess());

View File

@@ -23,7 +23,8 @@ public class Connector {
} }
public void startReconnect() { public void startReconnect() {
if (connectTicker != null && connectTicker.isActive()) return; if ((connectTicker != null && connectTicker.isActive()) ||
(client != null && client.isConnected())) return;
client = new Client(); client = new Client();
connectTicker = new TaskTicker().setStepTimeMs(5000L); connectTicker = new TaskTicker().setStepTimeMs(5000L);
connectTicker.setTask(() -> { connectTicker.setTask(() -> {