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/BlackKiteProtocolDecoder.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/org/traccar/protocol/BlackKiteProtocolDecoder.java') diff --git a/src/org/traccar/protocol/BlackKiteProtocolDecoder.java b/src/org/traccar/protocol/BlackKiteProtocolDecoder.java index 6787140e0..1c9c0a003 100644 --- a/src/org/traccar/protocol/BlackKiteProtocolDecoder.java +++ b/src/org/traccar/protocol/BlackKiteProtocolDecoder.java @@ -1,6 +1,6 @@ /* + * Copyright 2013 - 2016 Anton Tananaev (anton.tananaev@gmail.com) * Copyright 2015 Vijay Kumar (vijaykumar@zilogic.com) - * Copyright 2013 - 2014 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; +import org.traccar.DeviceSession; import org.traccar.helper.BitUtil; import org.traccar.helper.Log; import org.traccar.model.Position; @@ -96,9 +97,7 @@ public class BlackKiteProtocolDecoder extends BaseProtocolDecoder { switch (tag) { case TAG_IMEI: - String imei = buf.toString(buf.readerIndex(), 15, StandardCharsets.US_ASCII); - buf.skipBytes(imei.length()); - identify(imei, channel, remoteAddress); + getDeviceSession(channel, remoteAddress, buf.readBytes(15).toString(StandardCharsets.US_ASCII)); break; case TAG_DATE: @@ -174,15 +173,15 @@ public class BlackKiteProtocolDecoder extends BaseProtocolDecoder { positions.add(position); } - if (!hasDeviceId()) { - Log.warning("Unknown device"); + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress); + if (deviceSession == null) { return null; } sendReply(channel, buf.readUnsignedShort()); for (Position p : positions) { - p.setDeviceId(getDeviceId()); + p.setDeviceId(deviceSession.getDeviceId()); } if (positions.isEmpty()) { -- cgit v1.2.3