aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/HuaShengProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-06-07 16:48:41 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-06-07 16:48:41 +1200
commit7e324a9dfb2bcde08d1524a9f3dc5114c0d49bdc (patch)
tree0e5cba2fe3cc600478fb5f536e9abf485ef976d7 /src/org/traccar/protocol/HuaShengProtocolDecoder.java
parenta9be10be1cf3709a6f6eb5d612c2f5485f12749e (diff)
downloadtrackermap-server-7e324a9dfb2bcde08d1524a9f3dc5114c0d49bdc.tar.gz
trackermap-server-7e324a9dfb2bcde08d1524a9f3dc5114c0d49bdc.tar.bz2
trackermap-server-7e324a9dfb2bcde08d1524a9f3dc5114c0d49bdc.zip
Migrate H, I, J, K protocols
Diffstat (limited to 'src/org/traccar/protocol/HuaShengProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/HuaShengProtocolDecoder.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/org/traccar/protocol/HuaShengProtocolDecoder.java b/src/org/traccar/protocol/HuaShengProtocolDecoder.java
index 88f23b28c..05d0751a2 100644
--- a/src/org/traccar/protocol/HuaShengProtocolDecoder.java
+++ b/src/org/traccar/protocol/HuaShengProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 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,11 +15,12 @@
*/
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.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.UnitsConverter;
@@ -41,9 +42,9 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_HSO_REQ = 0x0002;
public static final int MSG_HSO_RSP = 0x0003;
- private void sendResponse(Channel channel, int type, int index, ChannelBuffer content) {
+ private void sendResponse(Channel channel, int type, int index, ByteBuf content) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer();
+ ByteBuf response = Unpooled.buffer();
response.writeByte(0xC0);
response.writeShort(0x0100);
response.writeShort(12 + (content != null ? content.readableBytes() : 0));
@@ -54,7 +55,7 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
response.writeBytes(content);
}
response.writeByte(0xC0);
- channel.write(response);
+ channel.write(new NetworkMessage(response, channel.remoteAddress()));
}
}
@@ -62,7 +63,7 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.skipBytes(1); // start marker
buf.readUnsignedByte(); // flag
@@ -83,7 +84,7 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
String imei = buf.readBytes(length).toString(StandardCharsets.US_ASCII);
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei);
if (deviceSession != null && channel != null) {
- ChannelBuffer content = ChannelBuffers.dynamicBuffer();
+ ByteBuf content = Unpooled.buffer();
content.writeByte(0); // success
sendResponse(channel, MSG_LOGIN_RSP, index, content);
}