From e177e7d083a4dd3f64172802661bf658d26d1163 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 1 Aug 2016 15:49:16 +1000 Subject: Check OsmAnd messages for device id --- src/org/traccar/protocol/OsmAndProtocolDecoder.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/org') diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java index f9f04d7e3..c5884a4d0 100644 --- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java +++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java @@ -73,9 +73,7 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder { case "deviceid": DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, value); if (deviceSession == null) { - if (channel != null) { - sendResponse(channel, HttpResponseStatus.BAD_REQUEST); - } + sendResponse(channel, HttpResponseStatus.BAD_REQUEST); return null; } position.setDeviceId(deviceSession.getDeviceId()); @@ -132,11 +130,14 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder { position.setTime(new Date()); } - if (channel != null) { + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress); + if (deviceSession != null) { sendResponse(channel, HttpResponseStatus.OK); + return position; + } else { + sendResponse(channel, HttpResponseStatus.BAD_REQUEST); + return null; } - - return position; } } -- cgit v1.2.3