aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/TaipProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-07-19 15:11:35 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2016-07-19 15:11:35 +1200
commit815c3de43ee8943fddb916f27317c37a7a806d65 (patch)
treea38e4f6bf80c35ccc83ae9d4c4d3d88e0d837b00 /src/org/traccar/protocol/TaipProtocolDecoder.java
parent4054777eac379ce07560c44901ada659aad062ba (diff)
downloadtrackermap-server-815c3de43ee8943fddb916f27317c37a7a806d65.tar.gz
trackermap-server-815c3de43ee8943fddb916f27317c37a7a806d65.tar.bz2
trackermap-server-815c3de43ee8943fddb916f27317c37a7a806d65.zip
Move device id to a session
Diffstat (limited to 'src/org/traccar/protocol/TaipProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/TaipProtocolDecoder.java33
1 files changed, 8 insertions, 25 deletions
diff --git a/src/org/traccar/protocol/TaipProtocolDecoder.java b/src/org/traccar/protocol/TaipProtocolDecoder.java
index f44b9bcbe..811db774c 100644
--- a/src/org/traccar/protocol/TaipProtocolDecoder.java
+++ b/src/org/traccar/protocol/TaipProtocolDecoder.java
@@ -17,6 +17,7 @@ package org.traccar.protocol;
import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
+import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.DateUtil;
import org.traccar.helper.Parser;
@@ -84,27 +85,6 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
sentence = sentence.substring(beginIndex + 1);
}
- // Find device identifier
- beginIndex = sentence.indexOf(";ID=");
- if (beginIndex != -1) {
- beginIndex += 4;
- int endIndex = sentence.indexOf(';', beginIndex);
- if (endIndex == -1) {
- endIndex = sentence.length();
- }
-
- String id = sentence.substring(beginIndex, endIndex);
- if (!identify(id, channel, remoteAddress)) {
- return null;
- }
-
- if (sendResponse && channel != null) {
- channel.write(id);
- }
- } else {
- return null;
- }
-
Parser parser = new Parser(PATTERN, sentence);
if (!parser.matches()) {
return null;
@@ -112,7 +92,6 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position();
position.setProtocol(getProtocolName());
- position.setDeviceId(getDeviceId());
String week = parser.next();
String day = parser.next();
@@ -157,8 +136,9 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
switch (key) {
case "id":
- if (!identify(value, channel, remoteAddress)) {
- return null;
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, value);
+ if (deviceSession != null) {
+ position.setDeviceId(deviceSession.getDeviceId());
}
if (sendResponse && channel != null) {
channel.write(value);
@@ -186,7 +166,10 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
}
}
- return position;
+ if (position.getDeviceId() != 0) {
+ return position;
+ }
+ return null;
}
}