From b52688409736837d952f10865be754e23120f42c Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Thu, 15 Jun 2017 00:43:47 +0200 Subject: more review --- src/org/traccar/protocol/OwnTracksProtocolDecoder.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/protocol/OwnTracksProtocolDecoder.java b/src/org/traccar/protocol/OwnTracksProtocolDecoder.java index 4bff3c7ed..f1dd2401a 100644 --- a/src/org/traccar/protocol/OwnTracksProtocolDecoder.java +++ b/src/org/traccar/protocol/OwnTracksProtocolDecoder.java @@ -94,15 +94,17 @@ public class OwnTracksProtocolDecoder extends BaseProtocolDecoder { position.setTime(new Date(root.getJsonNumber("tst").longValue() * 1000)); - String uniqueId = ""; - if (root.containsKey("tid")) { - uniqueId = root.getString("tid"); - } - if (root.containsKey("topic")) { + Boolean haveTopic = root.containsKey("topic"); + Boolean haveTid = root.containsKey("tid"); + String uniqueId = null; + + if (haveTopic) { uniqueId = root.getString("topic"); - if (root.containsKey("tid")) { + if (haveTid) { position.set("tid", root.getString("tid")); } + } else { + uniqueId = root.getString("tid"); } DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, uniqueId); @@ -115,5 +117,4 @@ public class OwnTracksProtocolDecoder extends BaseProtocolDecoder { sendResponse(channel, HttpResponseStatus.OK); return position; } - } -- cgit v1.2.3