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/TrackerEventHandler.java | |
parent | 68ef12c1844fd692aca86a848d268accadbe67be (diff) | |
download | trackermap-server-e2a855c53cad32d38a53ed65c0b899f59c99e646.tar.gz trackermap-server-e2a855c53cad32d38a53ed65c0b899f59c99e646.tar.bz2 trackermap-server-e2a855c53cad32d38a53ed65c0b899f59c99e646.zip |
Properly handle connection closing (fix #62)
Diffstat (limited to 'src/org/traccar/TrackerEventHandler.java')
-rw-r--r-- | src/org/traccar/TrackerEventHandler.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/org/traccar/TrackerEventHandler.java b/src/org/traccar/TrackerEventHandler.java index bd3e90160..6483e52e7 100644 --- a/src/org/traccar/TrackerEventHandler.java +++ b/src/org/traccar/TrackerEventHandler.java @@ -16,6 +16,8 @@ package org.traccar; import org.jboss.netty.channel.*; +import org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler; +import org.jboss.netty.handler.timeout.IdleStateEvent; import org.traccar.helper.Log; import org.traccar.model.DataManager; import org.traccar.model.Position; @@ -24,7 +26,7 @@ import org.traccar.model.Position; * Tracker message handler */ @ChannelHandler.Sharable -public class TrackerEventHandler extends SimpleChannelHandler { +public class TrackerEventHandler extends IdleStateAwareChannelHandler { /** * Data manager @@ -70,8 +72,21 @@ public class TrackerEventHandler extends SimpleChannelHandler { } @Override + public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) { + Log.info("Closing connection by disconnect"); + e.getChannel().close(); + } + + @Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) { + Log.info("Closing connection by exception"); e.getChannel().close(); } + @Override + public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) { + Log.info("Closing connection by timeout"); + e.getChannel().close(); + } + } |