aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/ProcessingHandler.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2024-03-31 07:14:34 -0700
committerAnton Tananaev <anton@traccar.org>2024-03-31 07:14:34 -0700
commit05283e44dea22f7b928401f888289840581b28af (patch)
tree9b42a508ad2f1c8af5015f6a0dfbdd772c917afb /src/main/java/org/traccar/ProcessingHandler.java
parent2d366f0ab3d88c635bec0f1f498396cd47557f1d (diff)
downloadtrackermap-server-05283e44dea22f7b928401f888289840581b28af.tar.gz
trackermap-server-05283e44dea22f7b928401f888289840581b28af.tar.bz2
trackermap-server-05283e44dea22f7b928401f888289840581b28af.zip
Simplify main event handler
Diffstat (limited to 'src/main/java/org/traccar/ProcessingHandler.java')
-rw-r--r--src/main/java/org/traccar/ProcessingHandler.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/ProcessingHandler.java b/src/main/java/org/traccar/ProcessingHandler.java
index 7627c719b..09ec79f9d 100644
--- a/src/main/java/org/traccar/ProcessingHandler.java
+++ b/src/main/java/org/traccar/ProcessingHandler.java
@@ -26,6 +26,7 @@ import org.traccar.handler.BasePositionHandler;
import org.traccar.handler.ComputedAttributesHandler;
import org.traccar.handler.CopyAttributesHandler;
import org.traccar.handler.DatabaseHandler;
+import org.traccar.handler.PostProcessHandler;
import org.traccar.handler.DistanceHandler;
import org.traccar.handler.EngineHoursHandler;
import org.traccar.handler.FilterHandler;
@@ -65,6 +66,7 @@ public class ProcessingHandler extends ChannelInboundHandlerAdapter {
private final NotificationManager notificationManager;
private final List<BasePositionHandler> positionHandlers;
private final List<BaseEventHandler> eventHandlers;
+ private final PostProcessHandler postProcessHandler;
@Inject
public ProcessingHandler(Injector injector, NotificationManager notificationManager) {
@@ -104,14 +106,17 @@ public class ProcessingHandler extends ChannelInboundHandlerAdapter {
.map((clazz) -> (BaseEventHandler) injector.getInstance(clazz))
.filter(Objects::nonNull)
.collect(Collectors.toUnmodifiableList());
+
+ postProcessHandler = injector.getInstance(PostProcessHandler.class);
}
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof Position) {
processPositionHandlers(ctx, (Position) msg);
+ } else {
+ super.channelRead(ctx, msg);
}
- super.channelRead(ctx, msg);
}
private void processPositionHandlers(ChannelHandlerContext ctx, Position position) {
@@ -139,7 +144,10 @@ public class ProcessingHandler extends ChannelInboundHandlerAdapter {
}
private void finishedProcessing(ChannelHandlerContext ctx, Position position) {
- ctx.writeAndFlush(new AcknowledgementHandler.EventHandled(position));
+ postProcessHandler.handlePosition(position, p -> {
+ ctx.fireChannelRead(p);
+ ctx.writeAndFlush(new AcknowledgementHandler.EventHandled(p));
+ });
}
}