aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-06-05 22:24:40 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-06-05 22:24:40 +1200
commitb8f4fc8888aaad7fe384c1dc2b80f44c1683bb03 (patch)
tree4252f76f9cc931993d071f5953253476d6965a60
parent1d04cfbd052946ac8eb00cd4c8045a31d4d75da3 (diff)
downloadtraccar-server-b8f4fc8888aaad7fe384c1dc2b80f44c1683bb03.tar.gz
traccar-server-b8f4fc8888aaad7fe384c1dc2b80f44c1683bb03.tar.bz2
traccar-server-b8f4fc8888aaad7fe384c1dc2b80f44c1683bb03.zip
Migrate Aplicom frame decoder
-rw-r--r--src/org/traccar/protocol/AplicomFrameDecoder.java24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/org/traccar/protocol/AplicomFrameDecoder.java b/src/org/traccar/protocol/AplicomFrameDecoder.java
index 24d55f1cf..083025077 100644
--- a/src/org/traccar/protocol/AplicomFrameDecoder.java
+++ b/src/org/traccar/protocol/AplicomFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,25 +15,25 @@
*/
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.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.ByteToMessageDecoder;
-public class AplicomFrameDecoder extends FrameDecoder {
+import java.util.List;
+
+public class AplicomFrameDecoder extends ByteToMessageDecoder {
@Override
- protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ protected void decode(ChannelHandlerContext ctx, ByteBuf buf, List<Object> out) throws Exception {
// Skip Alive message
- while (buf.readable() && Character.isDigit(buf.getByte(buf.readerIndex()))) {
+ while (buf.isReadable() && Character.isDigit(buf.getByte(buf.readerIndex()))) {
buf.readByte();
}
// Check minimum length
if (buf.readableBytes() < 11) {
- return null;
+ return;
}
// Read flags
@@ -53,10 +53,8 @@ public class AplicomFrameDecoder extends FrameDecoder {
// Return buffer
if (buf.readableBytes() >= length) {
- return buf.readBytes(length);
+ out.add(buf.readBytes(length));
}
-
- return null;
}
}