diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-06-09 09:35:25 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-06-09 09:35:25 +1200 |
commit | 4d88fa05bb1b673d676ff92b0b2b53bfba19cece (patch) | |
tree | 8b1241bbddfa6d17691e8318296e26f72e20a982 /src/org/traccar/protocol/ThinkRaceProtocolDecoder.java | |
parent | 46274ffddf31d0f09a7c370b2e374f53f6ecc2b6 (diff) | |
download | trackermap-server-4d88fa05bb1b673d676ff92b0b2b53bfba19cece.tar.gz trackermap-server-4d88fa05bb1b673d676ff92b0b2b53bfba19cece.tar.bz2 trackermap-server-4d88fa05bb1b673d676ff92b0b2b53bfba19cece.zip |
Migrate remaining protocols
Diffstat (limited to 'src/org/traccar/protocol/ThinkRaceProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/ThinkRaceProtocolDecoder.java | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/org/traccar/protocol/ThinkRaceProtocolDecoder.java b/src/org/traccar/protocol/ThinkRaceProtocolDecoder.java index f7dd18f51..dd1f34254 100644 --- a/src/org/traccar/protocol/ThinkRaceProtocolDecoder.java +++ b/src/org/traccar/protocol/ThinkRaceProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 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,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.model.CellTower; import org.traccar.model.Network; @@ -52,10 +53,10 @@ public class ThinkRaceProtocolDecoder extends BaseProtocolDecoder { protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { - ChannelBuffer buf = (ChannelBuffer) msg; + ByteBuf buf = (ByteBuf) msg; buf.skipBytes(2); // header - ChannelBuffer id = buf.readBytes(12); + ByteBuf id = buf.readBytes(12); buf.readUnsignedByte(); // separator int type = buf.readUnsignedByte(); buf.readUnsignedShort(); // length @@ -68,7 +69,7 @@ public class ThinkRaceProtocolDecoder extends BaseProtocolDecoder { String imei = buf.toString(buf.readerIndex(), 15, StandardCharsets.US_ASCII); DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei); if (deviceSession != null && channel != null) { - ChannelBuffer response = ChannelBuffers.dynamicBuffer(); + ByteBuf response = Unpooled.buffer(); response.writeByte(0x48); response.writeByte(0x52); // header response.writeBytes(id); response.writeByte(0x2c); // separator @@ -76,7 +77,7 @@ public class ThinkRaceProtocolDecoder extends BaseProtocolDecoder { response.writeShort(0x0002); // length response.writeShort(0x8000); response.writeShort(0x0000); // checksum - channel.write(response); + channel.writeAndFlush(new NetworkMessage(response, remoteAddress)); } } |