aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/handler/TimeHandler.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2024-03-30 18:46:37 -0700
committerAnton Tananaev <anton@traccar.org>2024-03-30 18:46:37 -0700
commitf84e2710e05660822633ec9e61cde44c03a42d7e (patch)
tree0d68bee50cc42ed206d270275dfb32b4b69c5186 /src/main/java/org/traccar/handler/TimeHandler.java
parentee996425221ca64fdf00777d9035cedc6dccfa43 (diff)
downloadtrackermap-server-f84e2710e05660822633ec9e61cde44c03a42d7e.tar.gz
trackermap-server-f84e2710e05660822633ec9e61cde44c03a42d7e.tar.bz2
trackermap-server-f84e2710e05660822633ec9e61cde44c03a42d7e.zip
Refactor position and event handlers
Diffstat (limited to 'src/main/java/org/traccar/handler/TimeHandler.java')
-rw-r--r--src/main/java/org/traccar/handler/TimeHandler.java15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/main/java/org/traccar/handler/TimeHandler.java b/src/main/java/org/traccar/handler/TimeHandler.java
index ef0c3445d..2e703c681 100644
--- a/src/main/java/org/traccar/handler/TimeHandler.java
+++ b/src/main/java/org/traccar/handler/TimeHandler.java
@@ -15,11 +15,7 @@
*/
package org.traccar.handler;
-import io.netty.channel.ChannelHandler;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
import jakarta.inject.Inject;
-import jakarta.inject.Singleton;
import org.traccar.config.Config;
import org.traccar.config.Keys;
import org.traccar.model.Position;
@@ -28,9 +24,7 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
-@Singleton
-@ChannelHandler.Sharable
-public class TimeHandler extends ChannelInboundHandlerAdapter {
+public class TimeHandler extends BasePositionHandler {
private final boolean enabled;
private final boolean useServerTime;
@@ -53,10 +47,9 @@ public class TimeHandler extends ChannelInboundHandlerAdapter {
}
@Override
- public void channelRead(ChannelHandlerContext ctx, Object msg) {
+ public void handlePosition(Position position, Callback callback) {
- if (enabled && msg instanceof Position) {
- Position position = (Position) msg;
+ if (enabled) {
if (protocols == null || protocols.contains(position.getProtocol())) {
if (useServerTime) {
position.setDeviceTime(position.getServerTime());
@@ -66,7 +59,7 @@ public class TimeHandler extends ChannelInboundHandlerAdapter {
}
}
}
- ctx.fireChannelRead(msg);
+ callback.processed(position);
}
}