diff options
author | Nikolay Vlahovski <nvlahovski@gmail.com> | 2023-05-17 11:00:43 +0300 |
---|---|---|
committer | Nikolay Vlahovski <nvlahovski@gmail.com> | 2023-05-17 11:00:43 +0300 |
commit | 7e403cf979d3c01acb5b3dfe0ee37dfa83cba4ff (patch) | |
tree | e4e8180b5a6e239279fbc4950b9a6db8409409ff /src/main/java/org/traccar/protocol/TranSyncProtocolDecoder.java | |
parent | 8ee05feeafbf7c6356e1afd65e140823c717aef8 (diff) | |
download | trackermap-server-7e403cf979d3c01acb5b3dfe0ee37dfa83cba4ff.tar.gz trackermap-server-7e403cf979d3c01acb5b3dfe0ee37dfa83cba4ff.tar.bz2 trackermap-server-7e403cf979d3c01acb5b3dfe0ee37dfa83cba4ff.zip |
Add LengthFieldBasedFrameDecoder to TranSyncProtocol
Diffstat (limited to 'src/main/java/org/traccar/protocol/TranSyncProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/TranSyncProtocolDecoder.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/protocol/TranSyncProtocolDecoder.java b/src/main/java/org/traccar/protocol/TranSyncProtocolDecoder.java index d07b70365..bb8c9bbf9 100644 --- a/src/main/java/org/traccar/protocol/TranSyncProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/TranSyncProtocolDecoder.java @@ -17,8 +17,10 @@ package org.traccar.protocol; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufUtil; +import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; +import org.traccar.NetworkMessage; import org.traccar.Protocol; import org.traccar.helper.BitUtil; import org.traccar.helper.DateBuilder; @@ -106,6 +108,18 @@ public class TranSyncProtocolDecoder extends BaseProtocolDecoder { } } + private void sendResponse(Channel channel) { + if (channel != null) { + ByteBuf response = Unpooled.buffer(5); + response.writeByte(22); + response.writeByte(1); + response.writeShort(response.capacity()); // length + response.writeByte(4); + + channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress())); + } + } + @Override protected Object decode(Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { ByteBuf buf = (ByteBuf) msg; @@ -189,6 +203,7 @@ public class TranSyncProtocolDecoder extends BaseProtocolDecoder { } } } + sendResponse(channel); return position; } } |