diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2011-11-02 11:45:35 +0000 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2011-11-02 11:45:35 +0000 |
commit | cc1f8e376ddbc7a5db0256e3ae7697774fa76dbd (patch) | |
tree | 220aacc30185dc01e17ec5d69424b776a5beb974 /src/net/sourceforge/opentracking/Server.java | |
parent | 234ad3b99d652f2a00f295f0f8c2e3e96125e1f2 (diff) | |
download | trackermap-server-cc1f8e376ddbc7a5db0256e3ae7697774fa76dbd.tar.gz trackermap-server-cc1f8e376ddbc7a5db0256e3ae7697774fa76dbd.tar.bz2 trackermap-server-cc1f8e376ddbc7a5db0256e3ae7697774fa76dbd.zip |
Diffstat (limited to 'src/net/sourceforge/opentracking/Server.java')
-rw-r--r-- | src/net/sourceforge/opentracking/Server.java | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/net/sourceforge/opentracking/Server.java b/src/net/sourceforge/opentracking/Server.java index 5d1332f38..b0fb8d96a 100644 --- a/src/net/sourceforge/opentracking/Server.java +++ b/src/net/sourceforge/opentracking/Server.java @@ -45,6 +45,7 @@ import net.sourceforge.opentracking.protocol.xexun.XexunProtocolDecoder; import net.sourceforge.opentracking.protocol.gps103.Gps103ProtocolDecoder; import net.sourceforge.opentracking.protocol.tk103.Tk103ProtocolDecoder; import net.sourceforge.opentracking.protocol.gl200.Gl200ProtocolDecoder; +import net.sourceforge.opentracking.protocol.t55.T55ProtocolDecoder; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.channel.ChannelPipelineFactory; @@ -445,7 +446,59 @@ public class Server implements DataManager { serverList.add(server); } + } + + /** + * T55 pipeline factory + */ + protected class T55PipelineFactory implements ChannelPipelineFactory { + + private TrackerServer server; + private Server serverCreator; + private Integer resetDelay; + + public T55PipelineFactory( + 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) '\r' }; + pipeline.addLast("frameDecoder", + new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter))); + pipeline.addLast("stringDecoder", new StringDecoder()); + pipeline.addLast("stringEncoder", new StringEncoder()); + pipeline.addLast("objectDecoder", new T55ProtocolDecoder(serverCreator, resetDelay)); + pipeline.addLast("handler", new TrackerEventHandler(serverCreator)); + return pipeline; + } } + + /** + * Init T55 server + */ + public void initT55Server(Properties properties) throws SQLException { + + boolean enable = Boolean.valueOf(properties.getProperty("t55.enable")); + if (enable) { + + TrackerServer server = new TrackerServer( + Integer.valueOf(properties.getProperty("t55.port"))); + + String resetDelay = properties.getProperty("t55.resetDelay"); + server.setPipelineFactory(new T55PipelineFactory( + server, this, (resetDelay == null) ? 0 : Integer.valueOf(resetDelay))); + + serverList.add(server); + } + } /** * Start |