diff options
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r-- | src/main/java/org/traccar/protocol/TeraTrackProtocolDecoder.java | 13 |
1 files changed, 3 insertions, 10 deletions
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; } |