diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2011-11-18 13:48:09 +0000 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2011-11-18 13:48:09 +0000 |
commit | 8b6816289e5c7a4db1cb7ddda5e49e4ace050fa1 (patch) | |
tree | 12a69c8f0791d1333aa220e1a2cce02901dd72e3 /src/org/traccar/Server.java | |
parent | 91a8d2558644293758c93d2c1df21487cd387993 (diff) | |
download | trackermap-server-8b6816289e5c7a4db1cb7ddda5e49e4ace050fa1.tar.gz trackermap-server-8b6816289e5c7a4db1cb7ddda5e49e4ace050fa1.tar.bz2 trackermap-server-8b6816289e5c7a4db1cb7ddda5e49e4ace050fa1.zip |
Diffstat (limited to 'src/org/traccar/Server.java')
-rw-r--r-- | src/org/traccar/Server.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/org/traccar/Server.java b/src/org/traccar/Server.java index 83e18a537..a747df536 100644 --- a/src/org/traccar/Server.java +++ b/src/org/traccar/Server.java @@ -53,6 +53,7 @@ import org.jboss.netty.channel.ChannelPipelineFactory; import org.jboss.netty.channel.ChannelStateEvent; import org.jboss.netty.channel.Channels; import org.jboss.netty.channel.SimpleChannelHandler; +import org.traccar.protocol.gl100.Gl100ProtocolDecoder; import org.traccar.protocol.xexun2.Xexun2ProtocolDecoder; /** @@ -94,6 +95,7 @@ public class Server implements DataManager { initXexunServer(properties); initGps103Server(properties); initTk103Server(properties); + initGl100Server(properties); initGl200Server(properties); initT55Server(properties); initXexun2Server(properties); @@ -399,6 +401,59 @@ public class Server implements DataManager { } /** + * Gl100 pipeline factory + */ + protected class Gl100PipelineFactory implements ChannelPipelineFactory { + + private TrackerServer server; + private Server serverCreator; + private Integer resetDelay; + + public Gl100PipelineFactory( + TrackerServer server, Server serverCreator, Integer resetDelay) { + this.server = server; + this.serverCreator = serverCreator; + this.resetDelay = resetDelay; + } + + public ChannelPipeline getPipeline() { + ChannelPipeline pipeline = Channels.pipeline(); + pipeline.addLast("openHandler", new OpenChannelHandler(server)); + if (serverCreator.isLoggerEnabled()) { + pipeline.addLast("logger", new LoggingHandler("logger")); + } + byte delimiter[] = { (byte) 0x0 }; + pipeline.addLast("frameDecoder", + new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter))); + pipeline.addLast("stringDecoder", new StringDecoder()); + pipeline.addLast("stringEncoder", new StringEncoder()); + pipeline.addLast("objectDecoder", new Gl100ProtocolDecoder(serverCreator, resetDelay)); + pipeline.addLast("handler", new TrackerEventHandler(serverCreator)); + return pipeline; + } + } + + /** + * Init Gl100 server + */ + public void initGl100Server(Properties properties) throws SQLException { + + boolean enable = Boolean.valueOf(properties.getProperty("gl100.enable")); + if (enable) { + + TrackerServer server = new TrackerServer( + Integer.valueOf(properties.getProperty("gl100.port"))); + + String resetDelay = properties.getProperty("gl100.resetDelay"); + server.setPipelineFactory(new Gl100PipelineFactory( + server, this, (resetDelay == null) ? 0 : Integer.valueOf(resetDelay))); + + serverList.add(server); + } + } + + + /** * Gl200 pipeline factory */ protected class Gl200PipelineFactory implements ChannelPipelineFactory { |