aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/Server.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2012-03-08 06:45:15 +0000
committerAnton Tananaev <anton.tananaev@gmail.com>2012-03-08 06:45:15 +0000
commit2298302ea7f3b4f09b52638355c2b86a952a8306 (patch)
tree5a002db45ab2847cb6fdb27f3c7ad8fe04afc83c /src/org/traccar/Server.java
parent23099b942619a2470e6ad5dace4146cecf16f300 (diff)
downloadtrackermap-server-2298302ea7f3b4f09b52638355c2b86a952a8306.tar.gz
trackermap-server-2298302ea7f3b4f09b52638355c2b86a952a8306.tar.bz2
trackermap-server-2298302ea7f3b4f09b52638355c2b86a952a8306.zip
Diffstat (limited to 'src/org/traccar/Server.java')
-rw-r--r--src/org/traccar/Server.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/org/traccar/Server.java b/src/org/traccar/Server.java
index 4ba9ec9fa..2fa9b8f1d 100644
--- a/src/org/traccar/Server.java
+++ b/src/org/traccar/Server.java
@@ -54,6 +54,7 @@ import org.jboss.netty.channel.SimpleChannelHandler;
import org.traccar.helper.AdvancedConnection;
import org.traccar.protocol.gl100.Gl100ProtocolDecoder;
import org.traccar.protocol.xexun2.Xexun2ProtocolDecoder;
+import org.traccar.protocol.avl08.Avl08ProtocolDecoder;
/**
* Server
@@ -98,6 +99,7 @@ public class Server implements DataManager {
initGl200Server(properties);
initT55Server(properties);
initXexun2Server(properties);
+ initAvl08Server(properties);
}
/**
@@ -601,6 +603,57 @@ public class Server implements DataManager {
}
/**
+ * AVL-08 pipeline factory
+ */
+ protected class Avl08PipelineFactory implements ChannelPipelineFactory {
+
+ private TrackerServer server;
+ private Server serverCreator;
+ private Integer resetDelay;
+
+ public Avl08PipelineFactory(
+ 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) '$', (byte) '$' }; // probably use \r\n
+ pipeline.addLast("frameDecoder",
+ new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter)));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("objectDecoder", new Avl08ProtocolDecoder(serverCreator, resetDelay));
+ pipeline.addLast("handler", new TrackerEventHandler(serverCreator));
+ return pipeline;
+ }
+ }
+
+ /**
+ * Init AVL-08 server
+ */
+ public void initAvl08Server(Properties properties) throws SQLException {
+
+ boolean enable = Boolean.valueOf(properties.getProperty("avl08.enable"));
+ if (enable) {
+
+ TrackerServer server = new TrackerServer(
+ Integer.valueOf(properties.getProperty("avl08.port")));
+
+ String resetDelay = properties.getProperty("avl08.resetDelay");
+ server.setPipelineFactory(new Xexun2PipelineFactory(
+ server, this, (resetDelay == null) ? 0 : Integer.valueOf(resetDelay)));
+
+ serverList.add(server);
+ }
+ }
+
+ /**
* Start
*/
public void start() {