| | |
| | | import com.ard.utils.util.ByteUtils; |
| | | import com.ard.utils.util.GisUtils; |
| | | import io.netty.buffer.ByteBuf; |
| | | import io.netty.buffer.EmptyByteBuf; |
| | | import io.netty.channel.ChannelHandler; |
| | | import io.netty.channel.ChannelHandlerContext; |
| | | import io.netty.channel.ChannelId; |
| | |
| | | * 从服务端收到新的数据时,这个方法会在收到消息时被调用 |
| | | */ |
| | | @Override |
| | | public void channelRead(ChannelHandlerContext ctx, Object msg1) throws Exception, IOException { |
| | | if(msg1 == null){ |
| | | public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception, IOException { |
| | | if(msg == null){ |
| | | return; |
| | | } |
| | | |
| | |
| | | String host = inSocket.getAddress().getHostAddress(); |
| | | int port = inSocket.getPort(); |
| | | ArdEquipRadar ardEquipRadar = ClientInitialize.tureConnectMap.get(host+":"+port); |
| | | // msg转Buf |
| | | ByteBuf buf = (ByteBuf) msg; |
| | | // 创建缓冲中字节数的字节数组 |
| | | byte[] byteArray = new byte[buf.readableBytes()]; |
| | | // 写入数组 |
| | | buf.readBytes(byteArray); |
| | | // 处理接收到的消息 |
| | | ByteBuf msg= (ByteBuf)msg1; |
| | | byte[] byteArray = new byte[msg.readableBytes()]; |
| | | msg.getBytes(msg.readerIndex(), byteArray); |
| | | byte[] bytes = MessageParsing.receiveCompletePacket(byteArray); |
| | | if (bytes != null) { |
| | | processData(ardEquipRadar, bytes); |