| | |
| | | import io.netty.buffer.ByteBuf; |
| | | import io.netty.buffer.EmptyByteBuf; |
| | | import io.netty.channel.*; |
| | | import io.netty.util.CharsetUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | |
| | |
| | | InetSocketAddress inSocket = (InetSocketAddress) ctx.channel().remoteAddress(); |
| | | String host = inSocket.getAddress().getHostAddress(); |
| | | int port = inSocket.getPort(); |
| | | //log.info("收到来自 {}:{} 的数据{}", host, port,msg.toString(CharsetUtil.UTF_8)); |
| | | ArdEquipRadar ardEquipRadar = BootNettyClientChannelCache.getRadar(host + ":" + port); |
| | | if (ardEquipRadar != null) { |
| | | // 创建缓冲中字节数的字节数组 |
| | | byte[] byteArray = new byte[msg.readableBytes()]; |
| | | // 写入数组 |
| | | msg.readBytes(byteArray); |
| | | // 处理接收到的消息 |
| | | byte[] bytes = MessageParsing.receiveCompletePacket(byteArray); |
| | | if (bytes != null) { |
| | | processData(ardEquipRadar, bytes); |
| | | } |
| | | //// 创建缓冲中字节数的字节数组 |
| | | //byte[] byteArray = new byte[msg.readableBytes()]; |
| | | //// 写入数组 |
| | | //msg.readBytes(byteArray); |
| | | //// 处理接收到的消息 |
| | | //byte[] bytes = MessageParsing.receiveCompletePacket(byteArray); |
| | | //if (bytes != null) { |
| | | // processData(ardEquipRadar, bytes); |
| | | //} |
| | | } |
| | | } |
| | | |