aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2024-03-30 15:23:00 -0700
committerAnton Tananaev <anton@traccar.org>2024-03-30 15:23:00 -0700
commitee996425221ca64fdf00777d9035cedc6dccfa43 (patch)
treeac44668b2c8189c404814e3429271949ce4575cf /src
parent8fe2d697064c88f5dadf5ca3aeca51ba7e925fd9 (diff)
downloadtrackermap-server-ee996425221ca64fdf00777d9035cedc6dccfa43.tar.gz
trackermap-server-ee996425221ca64fdf00777d9035cedc6dccfa43.tar.bz2
trackermap-server-ee996425221ca64fdf00777d9035cedc6dccfa43.zip
Improve time handler
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/handler/TimeHandler.java24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/main/java/org/traccar/handler/TimeHandler.java b/src/main/java/org/traccar/handler/TimeHandler.java
index 3c3e17450..ef0c3445d 100644
--- a/src/main/java/org/traccar/handler/TimeHandler.java
+++ b/src/main/java/org/traccar/handler/TimeHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2019 - 2022 Anton Tananaev (anton@traccar.org)
+ * Copyright 2019 - 2024 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.
@@ -18,13 +18,12 @@ package org.traccar.handler;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
-import org.traccar.BaseProtocolDecoder;
+import jakarta.inject.Inject;
+import jakarta.inject.Singleton;
import org.traccar.config.Config;
import org.traccar.config.Keys;
import org.traccar.model.Position;
-import jakarta.inject.Inject;
-import jakarta.inject.Singleton;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
@@ -56,17 +55,16 @@ public class TimeHandler extends ChannelInboundHandlerAdapter {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
- if (enabled && msg instanceof Position && (protocols == null
- || protocols.contains(ctx.pipeline().get(BaseProtocolDecoder.class).getProtocolName()))) {
-
+ if (enabled && msg instanceof Position) {
Position position = (Position) msg;
- if (useServerTime) {
- position.setDeviceTime(position.getServerTime());
- position.setFixTime(position.getServerTime());
- } else {
- position.setFixTime(position.getDeviceTime());
+ if (protocols == null || protocols.contains(position.getProtocol())) {
+ if (useServerTime) {
+ position.setDeviceTime(position.getServerTime());
+ position.setFixTime(position.getServerTime());
+ } else {
+ position.setFixTime(position.getDeviceTime());
+ }
}
-
}
ctx.fireChannelRead(msg);
}