diff options
author | ninioe <ninioe@gmail.com> | 2016-07-19 15:20:15 +0300 |
---|---|---|
committer | ninioe <ninioe@gmail.com> | 2016-07-19 15:20:15 +0300 |
commit | 20f603076210073e122c720e21a3e8999478b11a (patch) | |
tree | 668a50e6c55601c2420bf0f4b986ed0b194c2e32 /src/org/traccar/protocol/WialonProtocolDecoder.java | |
parent | e954e95547d05a34bbd36e3aa5003f4ddaf2ccd0 (diff) | |
parent | 00e2f8a3575855a8b863e245005b8f83b3314bfb (diff) | |
download | trackermap-server-20f603076210073e122c720e21a3e8999478b11a.tar.gz trackermap-server-20f603076210073e122c720e21a3e8999478b11a.tar.bz2 trackermap-server-20f603076210073e122c720e21a3e8999478b11a.zip |
Merge remote-tracking branch 'refs/remotes/tananaev/master'
Diffstat (limited to 'src/org/traccar/protocol/WialonProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/WialonProtocolDecoder.java | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/org/traccar/protocol/WialonProtocolDecoder.java b/src/org/traccar/protocol/WialonProtocolDecoder.java index 1de2f9dbf..627b93b1c 100644 --- a/src/org/traccar/protocol/WialonProtocolDecoder.java +++ b/src/org/traccar/protocol/WialonProtocolDecoder.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; @@ -66,16 +67,21 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder { } } - private Position decodePosition(String substring) { + private Position decodePosition(Channel channel, SocketAddress remoteAddress, String substring) { + + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress); + if (deviceSession == null) { + return null; + } Parser parser = new Parser(PATTERN, substring); - if (!hasDeviceId() || !parser.matches()) { + if (!parser.matches()) { return null; } Position position = new Position(); position.setProtocol(getProtocolName()); - position.setDeviceId(getDeviceId()); + position.setDeviceId(deviceSession.getDeviceId()); DateBuilder dateBuilder = new DateBuilder() .setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt()) @@ -129,7 +135,8 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder { if (sentence.startsWith("#L#")) { String imei = sentence.substring(3, sentence.indexOf(';')); - if (identify(imei, channel, remoteAddress)) { + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei); + if (deviceSession != null) { sendResponse(channel, "#AL#", 1); } @@ -140,7 +147,7 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder { } else if (sentence.startsWith("#SD#") || sentence.startsWith("#D#")) { Position position = decodePosition( - sentence.substring(sentence.indexOf('#', 1) + 1)); + channel, remoteAddress, sentence.substring(sentence.indexOf('#', 1) + 1)); if (position != null) { sendResponse(channel, "#AD#", 1); @@ -153,7 +160,7 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder { List<Position> positions = new LinkedList<>(); for (String message : messages) { - Position position = decodePosition(message); + Position position = decodePosition(channel, remoteAddress, message); if (position != null) { positions.add(position); } |