From 25dfb6a1fb66f5565ec338928d000d271f7e62db Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 21 Dec 2021 23:26:13 -0800 Subject: Encode response message --- src/main/java/org/traccar/protocol/TzoneProtocolDecoder.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/org/traccar/protocol/TzoneProtocolDecoder.java b/src/main/java/org/traccar/protocol/TzoneProtocolDecoder.java index 9e04f0b02..819c42471 100644 --- a/src/main/java/org/traccar/protocol/TzoneProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/TzoneProtocolDecoder.java @@ -17,6 +17,7 @@ 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.Context; @@ -33,6 +34,7 @@ import org.traccar.model.Network; import org.traccar.model.Position; import java.net.SocketAddress; +import java.nio.charset.StandardCharsets; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; @@ -51,8 +53,10 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder { String ack = String.format("@ACK,%d#", index); String time = String.format("@UTC time:%s", dateFormat.format(new Date())); + ByteBuf response = Unpooled.copiedBuffer(ack + time, StandardCharsets.US_ASCII); + if (channel != null) { - channel.writeAndFlush(new NetworkMessage(ack + time, remoteAddress)); + channel.writeAndFlush(new NetworkMessage(response, remoteAddress)); } } -- cgit v1.2.3