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 f5a67cc68..288719834 100644 --- a/src/org/traccar/Server.java +++ b/src/org/traccar/Server.java @@ -108,6 +108,7 @@ public class Server { initPt502Server(properties); initTr20Server(properties); initNavisServer(properties); + initMeitrackServer(properties); // Initialize web server if (Boolean.valueOf(properties.getProperty("http.enable"))) { @@ -712,4 +713,30 @@ public class Server { serverList.add(server); } } + + /** + * Init Meitrack server + */ + private void initMeitrackServer(Properties properties) throws SQLException { + + String protocol = "meitrack"; + 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 MeitrackProtocolDecoder(getDataManager())); + } + }); + + serverList.add(server); + } + } } |