diff options
author | Anton Tananaev <anton@traccar.org> | 2022-06-04 06:33:02 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-06-04 06:33:02 -0700 |
commit | ec76482c15094a7e04964c67d3011a7e8e1ad6a9 (patch) | |
tree | 3ef0d23e1b9f4ba7ef02f68b08db33f3db1972ab /src/main/java/org/traccar/BaseProtocolDecoder.java | |
parent | 4030d3207c157a3fcee2653c18440898b6b2a2e6 (diff) | |
download | trackermap-server-ec76482c15094a7e04964c67d3011a7e8e1ad6a9.tar.gz trackermap-server-ec76482c15094a7e04964c67d3011a7e8e1ad6a9.tar.bz2 trackermap-server-ec76482c15094a7e04964c67d3011a7e8e1ad6a9.zip |
Refactor commands manager
Diffstat (limited to 'src/main/java/org/traccar/BaseProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/BaseProtocolDecoder.java | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/BaseProtocolDecoder.java b/src/main/java/org/traccar/BaseProtocolDecoder.java index 71ef686fa..5b3f129de 100644 --- a/src/main/java/org/traccar/BaseProtocolDecoder.java +++ b/src/main/java/org/traccar/BaseProtocolDecoder.java @@ -15,7 +15,6 @@ */ package org.traccar; -import com.google.inject.Inject; import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; import org.traccar.config.Config; @@ -32,6 +31,7 @@ import org.traccar.session.ConnectionManager; import org.traccar.session.DeviceSession; import org.traccar.storage.StorageException; +import javax.inject.Inject; import java.net.InetSocketAddress; import java.net.SocketAddress; import java.util.Collection; @@ -51,6 +51,7 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder { private ConnectionManager connectionManager; private StatisticsManager statisticsManager; private MediaManager mediaManager; + private CommandsManager commandsManager; public BaseProtocolDecoder(Protocol protocol) { this.protocol = protocol; @@ -96,6 +97,15 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder { this.mediaManager = mediaManager; } + @Inject + public void setCommandsManager(CommandsManager commandsManager) { + this.commandsManager = commandsManager; + } + + public CommandsManager getCommandsManager() { + return commandsManager; + } + public String writeMediaFile(String uniqueId, ByteBuf buf, String extension) { return mediaManager.writeFile(uniqueId, buf, extension); } @@ -204,11 +214,8 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder { } protected void sendQueuedCommands(Channel channel, SocketAddress remoteAddress, long deviceId) { - CommandsManager commandsManager = Context.getCommandsManager(); - if (commandsManager != null) { - for (Command command : commandsManager.readQueuedCommands(deviceId)) { - protocol.sendDataCommand(channel, remoteAddress, command); - } + for (Command command : commandsManager.readQueuedCommands(deviceId)) { + protocol.sendDataCommand(channel, remoteAddress, command); } } |