diff options
Diffstat (limited to 'src/org/traccar/protocol/TrackboxProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/TrackboxProtocolDecoder.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/TrackboxProtocolDecoder.java b/src/org/traccar/protocol/TrackboxProtocolDecoder.java index 369409fc9..89253b891 100644 --- a/src/org/traccar/protocol/TrackboxProtocolDecoder.java +++ b/src/org/traccar/protocol/TrackboxProtocolDecoder.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.Parser; import org.traccar.helper.PatternBuilder; @@ -59,12 +60,17 @@ public class TrackboxProtocolDecoder extends BaseProtocolDecoder { if (sentence.startsWith("a=connect")) { String id = sentence.substring(sentence.indexOf("i=") + 2); - if (identify(id, channel, remoteAddress)) { + if (getDeviceSession(channel, remoteAddress, id) != null) { sendResponse(channel); } return null; } + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress); + if (deviceSession == null) { + return null; + } + Parser parser = new Parser(PATTERN, sentence); if (!parser.matches()) { return null; @@ -72,8 +78,8 @@ public class TrackboxProtocolDecoder extends BaseProtocolDecoder { sendResponse(channel); Position position = new Position(); - position.setDeviceId(getDeviceId()); position.setProtocol(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); DateBuilder dateBuilder = new DateBuilder() .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt(), parser.nextInt()); |