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/GenericPipelineFactory.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/GenericPipelineFactory.java')
-rw-r--r-- | src/org/traccar/GenericPipelineFactory.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/org/traccar/GenericPipelineFactory.java b/src/org/traccar/GenericPipelineFactory.java index c5e2cc812..d2012753e 100644 --- a/src/org/traccar/GenericPipelineFactory.java +++ b/src/org/traccar/GenericPipelineFactory.java @@ -19,6 +19,7 @@ import java.net.InetSocketAddress; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.*; import org.jboss.netty.handler.logging.LoggingHandler; +import org.jboss.netty.handler.timeout.IdleStateHandler; import org.traccar.geocode.ReverseGeocoder; import org.traccar.helper.Log; import org.traccar.model.DataManager; @@ -31,6 +32,7 @@ public abstract class GenericPipelineFactory implements ChannelPipelineFactory { private TrackerServer server; private DataManager dataManager; private Boolean loggerEnabled; + private Integer resetDelay; private ReverseGeocoder geocoder; /** @@ -86,10 +88,11 @@ public abstract class GenericPipelineFactory implements ChannelPipelineFactory { } public GenericPipelineFactory( - TrackerServer server, DataManager dataManager, Boolean loggerEnabled, ReverseGeocoder geocoder) { + TrackerServer server, DataManager dataManager, Boolean loggerEnabled, Integer resetDelay, ReverseGeocoder geocoder) { this.server = server; this.dataManager = dataManager; this.loggerEnabled = loggerEnabled; + this.resetDelay = resetDelay; this.geocoder = geocoder; } @@ -101,6 +104,9 @@ public abstract class GenericPipelineFactory implements ChannelPipelineFactory { public ChannelPipeline getPipeline() { ChannelPipeline pipeline = Channels.pipeline(); + if (resetDelay != 0) { + pipeline.addLast("idleHandler", new IdleStateHandler(GlobalTimer.getTimer(), resetDelay, 0, 0)); + } pipeline.addLast("openHandler", new OpenChannelHandler(server)); if (loggerEnabled) { pipeline.addLast("logger", new StandardLoggingHandler()); |