diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/traccar/handler/TimeHandler.java | 24 |
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); } |