aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/HoopoProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-10-21 20:26:45 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-10-21 20:26:45 -0700
commit36bcdfc80dc19bc932f03bc8a0da056f46023304 (patch)
treecdee146ba681fdaa3ce262026d28cd0d7ba7f550 /src/main/java/org/traccar/protocol/HoopoProtocolDecoder.java
parent7f1cb863872c01aaf7defa8164940b729eb86b77 (diff)
downloadtrackermap-server-36bcdfc80dc19bc932f03bc8a0da056f46023304.tar.gz
trackermap-server-36bcdfc80dc19bc932f03bc8a0da056f46023304.tar.bz2
trackermap-server-36bcdfc80dc19bc932f03bc8a0da056f46023304.zip
Expect TCP JSON data
Diffstat (limited to 'src/main/java/org/traccar/protocol/HoopoProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/HoopoProtocolDecoder.java14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/main/java/org/traccar/protocol/HoopoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HoopoProtocolDecoder.java
index 4f6b3d546..5db7f0bc0 100644
--- a/src/main/java/org/traccar/protocol/HoopoProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/HoopoProtocolDecoder.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.model.Position;
@@ -27,11 +25,10 @@ import javax.json.Json;
import javax.json.JsonObject;
import java.io.StringReader;
import java.net.SocketAddress;
-import java.nio.charset.StandardCharsets;
import java.time.OffsetDateTime;
import java.util.Date;
-public class HoopoProtocolDecoder extends BaseHttpProtocolDecoder {
+public class HoopoProtocolDecoder extends BaseProtocolDecoder {
public HoopoProtocolDecoder(Protocol protocol) {
super(protocol);
@@ -41,13 +38,10 @@ public class HoopoProtocolDecoder extends BaseHttpProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- FullHttpRequest request = (FullHttpRequest) msg;
- String content = request.content().toString(StandardCharsets.UTF_8);
- JsonObject json = Json.createReader(new StringReader(content)).readObject();
+ JsonObject json = Json.createReader(new StringReader((String) msg)).readObject();
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, json.getString("deviceId"));
if (deviceSession == null) {
- sendResponse(channel, HttpResponseStatus.BAD_REQUEST);
return null;
}
@@ -72,8 +66,6 @@ public class HoopoProtocolDecoder extends BaseHttpProtocolDecoder {
}
- sendResponse(channel, HttpResponseStatus.OK);
-
return null;
}