From 815c3de43ee8943fddb916f27317c37a7a806d65 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 19 Jul 2016 15:11:35 +1200 Subject: Move device id to a session --- src/org/traccar/protocol/CarscopProtocolDecoder.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/org/traccar/protocol/CarscopProtocolDecoder.java') diff --git a/src/org/traccar/protocol/CarscopProtocolDecoder.java b/src/org/traccar/protocol/CarscopProtocolDecoder.java index 4c1aced57..5e1973ae8 100644 --- a/src/org/traccar/protocol/CarscopProtocolDecoder.java +++ b/src/org/traccar/protocol/CarscopProtocolDecoder.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; @@ -53,12 +54,15 @@ public class CarscopProtocolDecoder extends BaseProtocolDecoder { String sentence = (String) msg; + DeviceSession deviceSession; int index = sentence.indexOf("UB05"); if (index != -1) { String imei = sentence.substring(index + 4, index + 4 + 15); - identify(imei, channel, remoteAddress); + deviceSession = getDeviceSession(channel, remoteAddress, imei); + } else { + deviceSession = getDeviceSession(channel, remoteAddress); } - if (!hasDeviceId()) { + if (deviceSession == null) { return null; } @@ -68,7 +72,7 @@ public class CarscopProtocolDecoder extends BaseProtocolDecoder { } Position position = new Position(); - position.setDeviceId(getDeviceId()); + position.setDeviceId(deviceSession.getDeviceId()); position.setProtocol(getProtocolName()); DateBuilder dateBuilder = new DateBuilder() -- cgit v1.2.3