diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-01-12 03:06:42 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-01-12 02:06:42 +1300 |
commit | bf3db6b69ebe36038232fee0de93f7cfbfea45a1 (patch) | |
tree | 2d3d280b82460732e9bb2c95f16ac9f2220d180a /src/org/traccar/MainEventHandler.java | |
parent | ca8397232467ca70db44b3b3b089409f7e9ee21a (diff) | |
download | trackermap-server-bf3db6b69ebe36038232fee0de93f7cfbfea45a1.tar.gz trackermap-server-bf3db6b69ebe36038232fee0de93f7cfbfea45a1.tar.bz2 trackermap-server-bf3db6b69ebe36038232fee0de93f7cfbfea45a1.zip |
Config option for non-persistent protocols (fix #2100)
Diffstat (limited to 'src/org/traccar/MainEventHandler.java')
-rw-r--r-- | src/org/traccar/MainEventHandler.java | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/org/traccar/MainEventHandler.java b/src/org/traccar/MainEventHandler.java index ec31c5efd..b67d7af84 100644 --- a/src/org/traccar/MainEventHandler.java +++ b/src/org/traccar/MainEventHandler.java @@ -29,9 +29,21 @@ import org.traccar.protocol.TeltonikaProtocolDecoder; import java.sql.SQLException; import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; public class MainEventHandler extends IdleStateAwareChannelHandler { + private final Set<String> connectionlessProtocols = new HashSet<>(); + + public MainEventHandler() { + String connectionlessProtocolList = Context.getConfig().getString("status.ignoreOffline"); + if (connectionlessProtocolList != null) { + connectionlessProtocols.addAll(Arrays.asList(connectionlessProtocolList.split(","))); + } + } + @Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) { @@ -80,8 +92,9 @@ public class MainEventHandler extends IdleStateAwareChannelHandler { Log.info(formatChannel(e.getChannel()) + " disconnected"); closeChannel(e.getChannel()); - if (ctx.getPipeline().get("httpDecoder") == null - && !(ctx.getPipeline().get("objectDecoder") instanceof TeltonikaProtocolDecoder)) { + BaseProtocolDecoder protocolDecoder = (BaseProtocolDecoder) ctx.getPipeline().get("objectDecoder"); + if (ctx.getPipeline().get("httpDecoder") == null && + !connectionlessProtocols.contains(protocolDecoder.getProtocolName())) { Context.getConnectionManager().removeActiveDevice(e.getChannel()); } } @@ -103,4 +116,5 @@ public class MainEventHandler extends IdleStateAwareChannelHandler { channel.close(); } } + } |