aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/Mta6ProtocolDecoder.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/Mta6ProtocolDecoder.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/Mta6ProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/Mta6ProtocolDecoder.java16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/org/traccar/protocol/Mta6ProtocolDecoder.java b/src/org/traccar/protocol/Mta6ProtocolDecoder.java
index 791a1acab..609f0b63e 100644
--- a/src/org/traccar/protocol/Mta6ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Mta6ProtocolDecoder.java
@@ -24,6 +24,7 @@ import org.jboss.netty.handler.codec.http.HttpResponse;
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
import org.jboss.netty.handler.codec.http.HttpVersion;
import org.traccar.BaseProtocolDecoder;
+import org.traccar.DeviceSession;
import org.traccar.Protocol;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
@@ -110,7 +111,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
}
- private List<Position> parseFormatA(ChannelBuffer buf) {
+ private List<Position> parseFormatA(DeviceSession deviceSession, ChannelBuffer buf) {
List<Position> positions = new LinkedList<>();
FloatReader latitudeReader = new FloatReader();
@@ -120,8 +121,8 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
try {
while (buf.readable()) {
Position position = new Position();
- position.setDeviceId(getDeviceId());
position.setProtocol(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
short flags = buf.readUnsignedByte();
@@ -197,9 +198,9 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
return positions;
}
- private Position parseFormatA1(ChannelBuffer buf) {
+ private Position parseFormatA1(DeviceSession deviceSession, ChannelBuffer buf) {
Position position = new Position();
- position.setDeviceId(getDeviceId());
+ position.setDeviceId(deviceSession.getDeviceId());
position.setProtocol(getProtocolName());
short flags = buf.readUnsignedByte();
@@ -283,7 +284,8 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
buf.skipBytes("id=".length());
int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '&');
String uniqueId = buf.toString(buf.readerIndex(), index - buf.readerIndex(), StandardCharsets.US_ASCII);
- if (!identify(uniqueId, channel, remoteAddress)) {
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, uniqueId);
+ if (deviceSession == null) {
return null;
}
buf.skipBytes(uniqueId.length());
@@ -303,9 +305,9 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
if (packetId == 0x31 || packetId == 0x32 || packetId == 0x36) {
if (simple) {
- return parseFormatA1(buf);
+ return parseFormatA1(deviceSession, buf);
} else {
- return parseFormatA(buf);
+ return parseFormatA(deviceSession, buf);
}
} //else if (0x34 0x38 0x4F 0x59)