aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/MegastekFrameDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol/MegastekFrameDecoder.java')
-rw-r--r--src/org/traccar/protocol/MegastekFrameDecoder.java22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/org/traccar/protocol/MegastekFrameDecoder.java b/src/org/traccar/protocol/MegastekFrameDecoder.java
index d9cb07108..347fa24b1 100644
--- a/src/org/traccar/protocol/MegastekFrameDecoder.java
+++ b/src/org/traccar/protocol/MegastekFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 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,19 +15,19 @@
*/
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 org.traccar.helper.StringFinder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
+import org.traccar.helper.BufferUtil;
import java.nio.charset.StandardCharsets;
-public class MegastekFrameDecoder extends FrameDecoder {
+public class MegastekFrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() < 10) {
return null;
@@ -36,18 +36,18 @@ public class MegastekFrameDecoder extends FrameDecoder {
if (Character.isDigit(buf.getByte(buf.readerIndex()))) {
int length = 4 + Integer.parseInt(buf.toString(buf.readerIndex(), 4, StandardCharsets.US_ASCII));
if (buf.readableBytes() >= length) {
- return buf.readBytes(length);
+ return buf.readRetainedSlice(length);
}
} else {
while (buf.getByte(buf.readerIndex()) == '\r' || buf.getByte(buf.readerIndex()) == '\n') {
buf.skipBytes(1);
}
- int delimiter = buf.indexOf(buf.readerIndex(), buf.writerIndex(), new StringFinder("\r\n"));
+ int delimiter = BufferUtil.indexOf("\r\n", buf);
if (delimiter == -1) {
delimiter = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '!');
}
if (delimiter != -1) {
- ChannelBuffer result = buf.readBytes(delimiter - buf.readerIndex());
+ ByteBuf result = buf.readRetainedSlice(delimiter - buf.readerIndex());
buf.skipBytes(1);
return result;
}