aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/AtrackProtocolDecoder.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/AtrackProtocolDecoder.java
parentb8f4fc8888aaad7fe384c1dc2b80f44c1683bb03 (diff)
downloadtrackermap-server-9c99076dc2416c4e0725007af0e5f2f2f444c05c.tar.gz
trackermap-server-9c99076dc2416c4e0725007af0e5f2f2f444c05c.tar.bz2
trackermap-server-9c99076dc2416c4e0725007af0e5f2f2f444c05c.zip
Migrate more protocols
Diffstat (limited to 'src/org/traccar/protocol/AtrackProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/AtrackProtocolDecoder.java21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/org/traccar/protocol/AtrackProtocolDecoder.java b/src/org/traccar/protocol/AtrackProtocolDecoder.java
index ac208c0f2..19746f31e 100644
--- a/src/org/traccar/protocol/AtrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/AtrackProtocolDecoder.java
@@ -15,12 +15,13 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
@@ -80,15 +81,15 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder {
private static void sendResponse(Channel channel, SocketAddress remoteAddress, long rawId, int index) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.directBuffer(12);
+ ByteBuf response = Unpooled.buffer(12);
response.writeShort(0xfe02);
response.writeLong(rawId);
response.writeShort(index);
- channel.write(response, remoteAddress);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
}
}
- private static String readString(ChannelBuffer buf) {
+ private static String readString(ByteBuf buf) {
String result = null;
int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) 0);
if (index > buf.readerIndex()) {
@@ -98,7 +99,7 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder {
return result;
}
- private void readCustomData(Position position, ChannelBuffer buf, String form) {
+ private void readCustomData(Position position, ByteBuf buf, String form) {
CellTower cellTower = new CellTower();
String[] keys = form.substring(1).split("%");
for (String key : keys) {
@@ -321,7 +322,7 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder {
return position;
}
- private List<Position> decodeBinary(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) {
+ private List<Position> decodeBinary(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
buf.skipBytes(2); // prefix
buf.readUnsignedShort(); // checksum
@@ -414,11 +415,11 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
if (buf.getUnsignedShort(buf.readerIndex()) == 0xfe02) {
if (channel != null) {
- channel.write(buf, remoteAddress); // keep-alive message
+ channel.writeAndFlush(new NetworkMessage(buf, remoteAddress)); // keep-alive message
}
return null;
} else if (buf.getByte(buf.readerIndex()) == '$') {