From 18d8ec9610944aee95aa01ffbe402f3d0c30c39a Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 4 Mar 2022 18:11:40 -0800 Subject: Fix TeraTrack protocol --- .../java/org/traccar/protocol/TeraTrackProtocolDecoder.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src/main/java/org/traccar') diff --git a/src/main/java/org/traccar/protocol/TeraTrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/TeraTrackProtocolDecoder.java index fadccccba..7cd678f8a 100644 --- a/src/main/java/org/traccar/protocol/TeraTrackProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/TeraTrackProtocolDecoder.java @@ -16,9 +16,7 @@ package org.traccar.protocol; import io.netty.channel.Channel; -import io.netty.handler.codec.http.FullHttpRequest; -import io.netty.handler.codec.http.HttpResponseStatus; -import org.traccar.BaseHttpProtocolDecoder; +import org.traccar.BaseProtocolDecoder; import org.traccar.DeviceSession; import org.traccar.Protocol; import org.traccar.helper.UnitsConverter; @@ -28,12 +26,11 @@ import javax.json.Json; import javax.json.JsonObject; import java.io.StringReader; import java.net.SocketAddress; -import java.nio.charset.StandardCharsets; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.TimeZone; -public class TeraTrackProtocolDecoder extends BaseHttpProtocolDecoder { +public class TeraTrackProtocolDecoder extends BaseProtocolDecoder { public TeraTrackProtocolDecoder(Protocol protocol) { super(protocol); @@ -43,15 +40,12 @@ public class TeraTrackProtocolDecoder extends BaseHttpProtocolDecoder { protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { - FullHttpRequest request = (FullHttpRequest) msg; - JsonObject json = Json.createReader( - new StringReader(request.content().toString(StandardCharsets.US_ASCII))).readObject(); + JsonObject json = Json.createReader(new StringReader((String) msg)).readObject(); String deviceId = json.getString("MDeviceID"); String imei = json.getString("IMEI"); DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, deviceId, imei); if (deviceSession == null) { - sendResponse(channel, HttpResponseStatus.NOT_FOUND); return null; } @@ -73,7 +67,6 @@ public class TeraTrackProtocolDecoder extends BaseHttpProtocolDecoder { position.set(Position.KEY_ODOMETER, Integer.parseInt(json.getString("Mileage"))); - sendResponse(channel, HttpResponseStatus.OK); return position; } -- cgit v1.2.3