aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/At2000FrameDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-01-12 02:37:54 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-01-12 01:37:54 +1300
commitca8397232467ca70db44b3b3b089409f7e9ee21a (patch)
tree20c9c8f40c8a0228b6be608b1f7c7fb2a84a9342 /src/org/traccar/protocol/At2000FrameDecoder.java
parentc03df5359224d86c8d1069872ddae52c0c35c225 (diff)
downloadtrackermap-server-ca8397232467ca70db44b3b3b089409f7e9ee21a.tar.gz
trackermap-server-ca8397232467ca70db44b3b3b089409f7e9ee21a.tar.bz2
trackermap-server-ca8397232467ca70db44b3b3b089409f7e9ee21a.zip
Avoid sending duplicate acks
Diffstat (limited to 'src/org/traccar/protocol/At2000FrameDecoder.java')
-rw-r--r--src/org/traccar/protocol/At2000FrameDecoder.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/org/traccar/protocol/At2000FrameDecoder.java b/src/org/traccar/protocol/At2000FrameDecoder.java
index 4c849afb7..f87dc3885 100644
--- a/src/org/traccar/protocol/At2000FrameDecoder.java
+++ b/src/org/traccar/protocol/At2000FrameDecoder.java
@@ -30,6 +30,9 @@ public class At2000FrameDecoder extends FrameDecoder {
private boolean firstPacket = true;
+ private ChannelBuffer currentBuffer;
+ private int acknowledgedBytes;
+
private void sendResponse(Channel channel) {
if (channel != null) {
ChannelBuffer response = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 2 * BLOCK_LENGTH);
@@ -63,7 +66,11 @@ public class At2000FrameDecoder extends FrameDecoder {
}
if (buf.readableBytes() >= length || buf.readableBytes() % ACK_LENGTH == 0) {
- sendResponse(channel);
+ if (buf != currentBuffer || buf.readableBytes() > acknowledgedBytes) {
+ sendResponse(channel);
+ currentBuffer = buf;
+ acknowledgedBytes = buf.readableBytes();
+ }
}
if (buf.readableBytes() >= length) {