diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-03-02 22:49:37 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2021-03-02 22:49:37 -0800 |
commit | 143670869a3e3fe36ff8a6f7075cfb42cd0259d1 (patch) | |
tree | 3a1723f48d626609be89450aa40eaeadcba3a3b0 /src/main/java/org/traccar/protocol | |
parent | b2f389803ffaed47082a6f770c5b19df98cecac2 (diff) | |
download | trackermap-server-143670869a3e3fe36ff8a6f7075cfb42cd0259d1.tar.gz trackermap-server-143670869a3e3fe36ff8a6f7075cfb42cd0259d1.tar.bz2 trackermap-server-143670869a3e3fe36ff8a6f7075cfb42cd0259d1.zip |
Fix response
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r-- | src/main/java/org/traccar/protocol/DolphinProtocolDecoder.java | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/protocol/DolphinProtocolDecoder.java b/src/main/java/org/traccar/protocol/DolphinProtocolDecoder.java index 8e57b18b5..e882c2378 100644 --- a/src/main/java/org/traccar/protocol/DolphinProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/DolphinProtocolDecoder.java @@ -45,7 +45,7 @@ public class DolphinProtocolDecoder extends BaseProtocolDecoder { ByteBuf buf = (ByteBuf) msg; buf.readUnsignedShort(); // header - buf.readUnsignedIntLE(); // index + int index = (int) buf.readUnsignedIntLE(); buf.readUnsignedShort(); // version buf.readUnsignedShort(); // flags int type = buf.readUnsignedShortLE(); @@ -64,11 +64,21 @@ public class DolphinProtocolDecoder extends BaseProtocolDecoder { ByteBufUtil.getBytes(buf, buf.readerIndex(), length, false)); if (channel != null) { - DolphinMessages.DataPackResponse response = DolphinMessages.DataPackResponse.newBuilder() + byte[] responseData = DolphinMessages.DataPackResponse.newBuilder() .setResponse(DolphinMessages.DataPackResponseCode.DataPack_OK) - .build(); - channel.writeAndFlush(new NetworkMessage( - Unpooled.wrappedBuffer(response.toByteArray()), remoteAddress)); + .build() + .toByteArray(); + + ByteBuf response = Unpooled.buffer(); + response.writeShort(0xABAB); // header + response.writeIntLE(index); + response.writeShort(0); // flags + response.writeShortLE(DolphinMessages.MessageType.DataPack_Response.getNumber()); + response.writeIntLE(responseData.length); + response.writeIntLE(0); // reserved + response.writeBytes(responseData); + + channel.writeAndFlush(new NetworkMessage(response, remoteAddress)); } List<Position> positions = new LinkedList<>(); |