aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/AlematicsFrameDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-06-05 23:16:21 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-06-05 23:16:21 +1200
commit9c99076dc2416c4e0725007af0e5f2f2f444c05c (patch)
tree55068f2ab5dbe99fcd60acc01c1bb05fc365aa43 /src/org/traccar/protocol/AlematicsFrameDecoder.java
parentb8f4fc8888aaad7fe384c1dc2b80f44c1683bb03 (diff)
downloadtraccar-server-9c99076dc2416c4e0725007af0e5f2f2f444c05c.tar.gz
traccar-server-9c99076dc2416c4e0725007af0e5f2f2f444c05c.tar.bz2
traccar-server-9c99076dc2416c4e0725007af0e5f2f2f444c05c.zip
Migrate more protocols
Diffstat (limited to 'src/org/traccar/protocol/AlematicsFrameDecoder.java')
-rw-r--r--src/org/traccar/protocol/AlematicsFrameDecoder.java18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/org/traccar/protocol/AlematicsFrameDecoder.java b/src/org/traccar/protocol/AlematicsFrameDecoder.java
index b8b3e3403..daac868c0 100644
--- a/src/org/traccar/protocol/AlematicsFrameDecoder.java
+++ b/src/org/traccar/protocol/AlematicsFrameDecoder.java
@@ -15,10 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import org.traccar.NetworkMessage;
public class AlematicsFrameDecoder extends LineBasedFrameDecoder {
@@ -31,20 +31,20 @@ public class AlematicsFrameDecoder extends LineBasedFrameDecoder {
// example of heartbeat: FA F8 00 07 00 03 15 AD 4E 78 3A D2
@Override
- protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ protected Object decode(ChannelHandlerContext ctx, ByteBuf buf) throws Exception {
if (buf.readableBytes() < MESSAGE_MINIMUM_LENGTH) {
return null;
}
if (buf.getUnsignedShort(buf.readerIndex()) == 0xFAF8) {
- ChannelBuffer heartbeat = buf.readBytes(12);
- if (channel != null) {
- channel.write(heartbeat);
+ ByteBuf heartbeat = buf.readBytes(12);
+ if (ctx != null && ctx.channel() != null) {
+ ctx.channel().writeAndFlush(new NetworkMessage(heartbeat, ctx.channel().remoteAddress()));
}
}
- return super.decode(ctx, channel, buf);
+ return super.decode(ctx, buf);
}
}