diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2012-11-02 23:22:25 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2012-11-02 23:22:25 +1300 |
commit | 119b1a9562aee0072c034017405df4cc94feaf35 (patch) | |
tree | 5f2f1faf98f598fdd5f5f014e01ca489f7119e9f /src/org | |
parent | 73f1943342354f5a3922561ca7ebefad239ce153 (diff) | |
download | traccar-server-119b1a9562aee0072c034017405df4cc94feaf35.tar.gz traccar-server-119b1a9562aee0072c034017405df4cc94feaf35.tar.bz2 traccar-server-119b1a9562aee0072c034017405df4cc94feaf35.zip |
Add PT502 protocol (fix #75)
Diffstat (limited to 'src/org')
-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 8dd55431f..051d040b9 100644 --- a/src/org/traccar/Server.java +++ b/src/org/traccar/Server.java @@ -103,6 +103,7 @@ public class Server { initJt600Server(properties); initEv603Server(properties); initV680Server(properties); + initPt502Server(properties); // Initialize web server if (Boolean.valueOf(properties.getProperty("http.enable"))) { @@ -625,4 +626,30 @@ public class Server { serverList.add(server); } } + + /** + * Init PT502 server + */ + private void initPt502Server(Properties properties) throws SQLException { + + String protocol = "pt502"; + 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 Pt502ProtocolDecoder(getDataManager())); + } + }); + + serverList.add(server); + } + } } |