diff options
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); + } + } } |