aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-03-22 07:57:06 -0700
committerAnton Tananaev <anton@traccar.org>2023-03-22 07:57:06 -0700
commit2bb447924b834693f4d97585f1e5e9e822b62fe3 (patch)
tree652747c72cc814fe038dbcd21298d8f26553e164 /src/main/java/org/traccar
parent5f56a56d77216fa46a63eabbcef67d59d4d7c817 (diff)
downloadtrackermap-server-2bb447924b834693f4d97585f1e5e9e822b62fe3.tar.gz
trackermap-server-2bb447924b834693f4d97585f1e5e9e822b62fe3.tar.bz2
trackermap-server-2bb447924b834693f4d97585f1e5e9e822b62fe3.zip
Encoder bypass other events
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r--src/main/java/org/traccar/BaseProtocolEncoder.java45
1 files changed, 22 insertions, 23 deletions
diff --git a/src/main/java/org/traccar/BaseProtocolEncoder.java b/src/main/java/org/traccar/BaseProtocolEncoder.java
index 9c3934184..96de3e3f0 100644
--- a/src/main/java/org/traccar/BaseProtocolEncoder.java
+++ b/src/main/java/org/traccar/BaseProtocolEncoder.java
@@ -71,31 +71,30 @@ public abstract class BaseProtocolEncoder extends ChannelOutboundHandlerAdapter
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
- NetworkMessage networkMessage = (NetworkMessage) msg;
-
- if (networkMessage.getMessage() instanceof Command) {
-
- Command command = (Command) networkMessage.getMessage();
- Object encodedCommand = encodeCommand(ctx.channel(), command);
-
- StringBuilder s = new StringBuilder();
- s.append("[").append(NetworkUtil.session(ctx.channel())).append("] ");
- s.append("id: ").append(getUniqueId(command.getDeviceId())).append(", ");
- s.append("command type: ").append(command.getType()).append(" ");
- if (encodedCommand != null) {
- s.append("sent");
- } else {
- s.append("not sent");
+ if (msg instanceof NetworkMessage) {
+ NetworkMessage networkMessage = (NetworkMessage) msg;
+ if (networkMessage.getMessage() instanceof Command) {
+
+ Command command = (Command) networkMessage.getMessage();
+ Object encodedCommand = encodeCommand(ctx.channel(), command);
+
+ StringBuilder s = new StringBuilder();
+ s.append("[").append(NetworkUtil.session(ctx.channel())).append("] ");
+ s.append("id: ").append(getUniqueId(command.getDeviceId())).append(", ");
+ s.append("command type: ").append(command.getType()).append(" ");
+ if (encodedCommand != null) {
+ s.append("sent");
+ } else {
+ s.append("not sent");
+ }
+ LOGGER.info(s.toString());
+
+ ctx.write(new NetworkMessage(encodedCommand, networkMessage.getRemoteAddress()), promise);
+
+ return;
}
- LOGGER.info(s.toString());
-
- ctx.write(new NetworkMessage(encodedCommand, networkMessage.getRemoteAddress()), promise);
-
- } else {
-
- super.write(ctx, msg, promise);
-
}
+ super.write(ctx, msg, promise);
}
protected Object encodeCommand(Channel channel, Command command) {