diff options
author | Anton Tananaev <anton@traccar.org> | 2024-03-30 18:46:37 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2024-03-30 18:46:37 -0700 |
commit | f84e2710e05660822633ec9e61cde44c03a42d7e (patch) | |
tree | 0d68bee50cc42ed206d270275dfb32b4b69c5186 /src/main/java/org/traccar/handler/DistanceHandler.java | |
parent | ee996425221ca64fdf00777d9035cedc6dccfa43 (diff) | |
download | trackermap-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/DistanceHandler.java')
-rw-r--r-- | src/main/java/org/traccar/handler/DistanceHandler.java | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/main/java/org/traccar/handler/DistanceHandler.java b/src/main/java/org/traccar/handler/DistanceHandler.java index db8c73779..ee5d64894 100644 --- a/src/main/java/org/traccar/handler/DistanceHandler.java +++ b/src/main/java/org/traccar/handler/DistanceHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2023 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2024 Anton Tananaev (anton@traccar.org) * Copyright 2015 Amila Silva * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,19 +16,14 @@ */ package org.traccar.handler; -import io.netty.channel.ChannelHandler; import jakarta.inject.Inject; -import jakarta.inject.Singleton; -import org.traccar.BaseDataHandler; import org.traccar.config.Config; import org.traccar.config.Keys; import org.traccar.helper.DistanceCalculator; import org.traccar.model.Position; import org.traccar.session.cache.CacheManager; -@Singleton -@ChannelHandler.Sharable -public class DistanceHandler extends BaseDataHandler { +public class DistanceHandler extends BasePositionHandler { private final CacheManager cacheManager; @@ -45,7 +40,7 @@ public class DistanceHandler extends BaseDataHandler { } @Override - protected Position handlePosition(Position position) { + public void handlePosition(Position position, Callback callback) { double distance = 0.0; if (position.hasAttribute(Position.KEY_DISTANCE)) { @@ -76,7 +71,7 @@ public class DistanceHandler extends BaseDataHandler { position.set(Position.KEY_DISTANCE, distance); position.set(Position.KEY_TOTAL_DISTANCE, totalDistance + distance); - return position; + callback.processed(position); } } |