‘liusuyi’
2023-12-28 c324f00db69c760b0c4c577425214d4ab2e34d9c
更改雷达tcp客户端
已修改1个文件
14 ■■■■■ 文件已修改
src/main/java/com/ard/utils/netty/tcp/BootNettyChannelInboundHandlerAdapter.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ard/utils/netty/tcp/BootNettyChannelInboundHandlerAdapter.java
@@ -8,6 +8,7 @@
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;
@@ -34,8 +35,8 @@
     * 从服务端收到新的数据时,这个方法会在收到消息时被调用
     */
    @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;
        }
@@ -49,10 +50,13 @@
        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);