From e2a855c53cad32d38a53ed65c0b899f59c99e646 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 31 Oct 2012 23:27:09 +1300 Subject: Properly handle connection closing (fix #62) --- src/org/traccar/GenericProtocolDecoder.java | 46 +---------------------------- 1 file changed, 1 insertion(+), 45 deletions(-) (limited to 'src/org/traccar/GenericProtocolDecoder.java') 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 @@ -45,18 +45,6 @@ public abstract class GenericProtocolDecoder extends OneToOneDecoder { return dataManager; } - /** - * Reset connection delay - */ - private Integer resetDelay; - - /** - * Set reset connection delay - */ - public final void setResetDelay(Integer resetDelay) { - this.resetDelay = resetDelay; - } - /** * Default constructor */ @@ -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); - } - } } } -- cgit v1.2.3