diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2012-10-31 23:27:09 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2012-10-31 23:27:09 +1300 |
commit | e2a855c53cad32d38a53ed65c0b899f59c99e646 (patch) | |
tree | 7e20ce16641392d6d769232f224e7454e20b53eb /src/org/traccar/GenericProtocolDecoder.java | |
parent | 68ef12c1844fd692aca86a848d268accadbe67be (diff) | |
download | traccar-server-e2a855c53cad32d38a53ed65c0b899f59c99e646.tar.gz traccar-server-e2a855c53cad32d38a53ed65c0b899f59c99e646.tar.bz2 traccar-server-e2a855c53cad32d38a53ed65c0b899f59c99e646.zip |
Properly handle connection closing (fix #62)
Diffstat (limited to 'src/org/traccar/GenericProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/GenericProtocolDecoder.java | 46 |
1 files changed, 1 insertions, 45 deletions
diff --git a/src/org/traccar/GenericProtocolDecoder.java b/src/org/traccar/GenericProtocolDecoder.java index b6755f95e..440b37dcb 100644 --- a/src/org/traccar/GenericProtocolDecoder.java +++ b/src/org/traccar/GenericProtocolDecoder.java @@ -46,18 +46,6 @@ public abstract class GenericProtocolDecoder extends OneToOneDecoder { } /** - * Reset connection delay - */ - private Integer resetDelay; - - /** - * Set reset connection delay - */ - public final void setResetDelay(Integer resetDelay) { - this.resetDelay = resetDelay; - } - - /** * Default constructor */ public GenericProtocolDecoder() { @@ -66,40 +54,8 @@ public abstract class GenericProtocolDecoder extends OneToOneDecoder { /** * Initialize */ - public GenericProtocolDecoder(DataManager dataManager, Integer resetDelay) { + public GenericProtocolDecoder(DataManager dataManager) { setDataManager(dataManager); - setResetDelay(resetDelay); - } - - /** - * Disconnect channel - */ - private class DisconnectTask extends TimerTask { - private Channel channel; - - public DisconnectTask(Channel channel) { - this.channel = channel; - } - - public void run() { - channel.disconnect(); - } - } - - /** - * Handle connect event - */ - @Override - public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent evt) throws Exception { - super.handleUpstream(ctx, evt); - - if (evt instanceof ChannelStateEvent) { - ChannelStateEvent event = (ChannelStateEvent) evt; - - if (event.getState() == ChannelState.CONNECTED && event.getValue() != null && resetDelay != 0) { - new Timer().schedule(new GenericProtocolDecoder.DisconnectTask(evt.getChannel()), resetDelay); - } - } } } |