aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/BaseProtocolEncoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-06-03 11:46:55 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-06-03 11:46:55 +1200
commitf0d1a5df7aecf1237609200d3ecb7cdd3d0abcab (patch)
treec82ad82bdb77e0e33340d6a020dc0912448f60d8 /src/org/traccar/BaseProtocolEncoder.java
parent06e3bd8b16da12baafc9a97ba5949b3f7ffb5e07 (diff)
downloadtrackermap-server-f0d1a5df7aecf1237609200d3ecb7cdd3d0abcab.tar.gz
trackermap-server-f0d1a5df7aecf1237609200d3ecb7cdd3d0abcab.tar.bz2
trackermap-server-f0d1a5df7aecf1237609200d3ecb7cdd3d0abcab.zip
Properly handle datagram channels
Diffstat (limited to 'src/org/traccar/BaseProtocolEncoder.java')
-rw-r--r--src/org/traccar/BaseProtocolEncoder.java16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/org/traccar/BaseProtocolEncoder.java b/src/org/traccar/BaseProtocolEncoder.java
index db4f2cbbf..ed71b5551 100644
--- a/src/org/traccar/BaseProtocolEncoder.java
+++ b/src/org/traccar/BaseProtocolEncoder.java
@@ -44,8 +44,11 @@ public abstract class BaseProtocolEncoder extends ChannelOutboundHandlerAdapter
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
- if (msg instanceof Command) {
- Command command = (Command) msg;
+ NetworkMessage networkMessage = (NetworkMessage) msg;
+
+ if (networkMessage.getMessage() instanceof Command) {
+
+ Command command = (Command) networkMessage.getMessage();
Object encodedCommand = encodeCommand(ctx.channel(), command);
StringBuilder s = new StringBuilder();
@@ -59,10 +62,13 @@ public abstract class BaseProtocolEncoder extends ChannelOutboundHandlerAdapter
}
Log.info(s.toString());
- super.write(ctx, encodedCommand, promise);
- }
+ ctx.write(new NetworkMessage(encodedCommand, networkMessage.getRemoteAddress()), promise);
- super.write(ctx, msg, promise);
+ } else {
+
+ super.write(ctx, msg, promise);
+
+ }
}
protected Object encodeCommand(Channel channel, Command command) {