aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/ExtendedObjectDecoder.java
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2024-03-07 22:59:12 -0600
committerIván Ávalos <avalos@disroot.org>2024-03-07 22:59:12 -0600
commit00d3ddf7b5e335a5112a28a547c4c9ec2c3bd1d2 (patch)
treea02ecb75a8533194314d32c0c667520bff5e919d /src/main/java/org/traccar/ExtendedObjectDecoder.java
parent8e1bc703227a875c20e453704d774ce5772f2621 (diff)
parent75b404db5c790bf37c05fabf1cbbd2027ad1db25 (diff)
downloadtrackermap-server-00d3ddf7b5e335a5112a28a547c4c9ec2c3bd1d2.tar.gz
trackermap-server-00d3ddf7b5e335a5112a28a547c4c9ec2c3bd1d2.tar.bz2
trackermap-server-00d3ddf7b5e335a5112a28a547c4c9ec2c3bd1d2.zip
Merge branch 'master' of https://github.com/traccar/traccar
Diffstat (limited to 'src/main/java/org/traccar/ExtendedObjectDecoder.java')
-rw-r--r--src/main/java/org/traccar/ExtendedObjectDecoder.java14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/ExtendedObjectDecoder.java b/src/main/java/org/traccar/ExtendedObjectDecoder.java
index f79a36c85..cddddcd80 100644
--- a/src/main/java/org/traccar/ExtendedObjectDecoder.java
+++ b/src/main/java/org/traccar/ExtendedObjectDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2020 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2023 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,13 +23,15 @@ import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.util.ReferenceCountUtil;
import org.traccar.config.Config;
import org.traccar.config.Keys;
+import org.traccar.handler.AcknowledgementHandler;
import org.traccar.helper.DataConverter;
import org.traccar.model.Position;
-import javax.inject.Inject;
+import jakarta.inject.Inject;
import java.net.SocketAddress;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
+import java.util.List;
public abstract class ExtendedObjectDecoder extends ChannelInboundHandlerAdapter {
@@ -68,6 +70,7 @@ public abstract class ExtendedObjectDecoder extends ChannelInboundHandlerAdapter
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
NetworkMessage networkMessage = (NetworkMessage) msg;
Object originalMessage = networkMessage.getMessage();
+ ctx.writeAndFlush(new AcknowledgementHandler.EventReceived());
try {
Object decodedMessage = decode(ctx.channel(), networkMessage.getRemoteAddress(), originalMessage);
onMessageEvent(ctx.channel(), networkMessage.getRemoteAddress(), originalMessage, decodedMessage);
@@ -76,14 +79,19 @@ public abstract class ExtendedObjectDecoder extends ChannelInboundHandlerAdapter
}
if (decodedMessage != null) {
if (decodedMessage instanceof Collection) {
- for (Object o : (Collection) decodedMessage) {
+ var collection = (Collection) decodedMessage;
+ ctx.writeAndFlush(new AcknowledgementHandler.EventDecoded(collection));
+ for (Object o : collection) {
saveOriginal(o, originalMessage);
ctx.fireChannelRead(o);
}
} else {
+ ctx.writeAndFlush(new AcknowledgementHandler.EventDecoded(List.of(decodedMessage)));
saveOriginal(decodedMessage, originalMessage);
ctx.fireChannelRead(decodedMessage);
}
+ } else {
+ ctx.writeAndFlush(new AcknowledgementHandler.EventDecoded(List.of()));
}
} finally {
ReferenceCountUtil.release(originalMessage);