diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2012-11-13 21:58:17 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2012-11-13 21:58:17 +1300 |
commit | 3ee4d2fba538eee4d1774bd79e07c64dc0af97e5 (patch) | |
tree | aaf69aa6b63874ccb226f966b2681746eee28a65 /src/org/traccar/Server.java | |
parent | f0d4f9de581b1f579608cbc3f5165c0b14317993 (diff) | |
download | trackermap-server-3ee4d2fba538eee4d1774bd79e07c64dc0af97e5.tar.gz trackermap-server-3ee4d2fba538eee4d1774bd79e07c64dc0af97e5.tar.bz2 trackermap-server-3ee4d2fba538eee4d1774bd79e07c64dc0af97e5.zip |
Added TR20 support (Fix #79)
Diffstat (limited to 'src/org/traccar/Server.java')
-rw-r--r-- | src/org/traccar/Server.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/org/traccar/Server.java b/src/org/traccar/Server.java index 051d040b9..38f0a1388 100644 --- a/src/org/traccar/Server.java +++ b/src/org/traccar/Server.java @@ -104,6 +104,7 @@ public class Server { initEv603Server(properties); initV680Server(properties); initPt502Server(properties); + initTr20Server(properties); // Initialize web server if (Boolean.valueOf(properties.getProperty("http.enable"))) { @@ -652,4 +653,30 @@ public class Server { serverList.add(server); } } + + /** + * Init TR20 server + */ + private void initTr20Server(Properties properties) throws SQLException { + + String protocol = "tr20"; + if (isProtocolEnabled(properties, protocol)) { + + TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol)); + final Integer resetDelay = getProtocolResetDelay(properties, protocol); + + server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) { + protected void addSpecificHandlers(ChannelPipeline pipeline) { + byte delimiter[] = { (byte) '\r', (byte) '\n' }; + pipeline.addLast("frameDecoder", + new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter))); + pipeline.addLast("stringDecoder", new StringDecoder()); + pipeline.addLast("stringEncoder", new StringEncoder()); + pipeline.addLast("objectDecoder", new Tr20ProtocolDecoder(getDataManager())); + } + }); + + serverList.add(server); + } + } } |