aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/TaipProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-07-19 22:25:12 +1200
committerGitHub <noreply@github.com>2016-07-19 22:25:12 +1200
commit4ebf7c5a6df152af9c23eb9caab2885ff79e448c (patch)
tree3dfcd0b379e71f1fc85b626179a72e14489aeb47 /src/org/traccar/protocol/TaipProtocolDecoder.java
parent934371a0af815e18b3d29f350e96be60606de77b (diff)
parent1a0eae22fc58d7241e2c60bb593535a17d6c629b (diff)
downloadtrackermap-server-4ebf7c5a6df152af9c23eb9caab2885ff79e448c.tar.gz
trackermap-server-4ebf7c5a6df152af9c23eb9caab2885ff79e448c.tar.bz2
trackermap-server-4ebf7c5a6df152af9c23eb9caab2885ff79e448c.zip
Merge pull request #2127 from tananaev/refactor
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;
}
}