自动化立体仓库 - WCS系统
#
18516761980
2022-07-30 9efa9a5bc1c36a7061a909ff9d315b9e616876ef
src/main/java/com/zy/core/netty/handle/ProtocolDecoder.java
@@ -23,18 +23,12 @@
        this.snowflakeIdWorker = snowflakeIdWorker;
    }
    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> list) throws Exception {
        int startMark = indexOfStartMark(in);
        if (startMark == -1){
            return;
        }
        // 去除无用前缀报文
        if (startMark != 0){
            in.readerIndex(startMark);
            in.discardReadBytes();
        }
        byte[] bytes = new byte[in.readableBytes()];
        in.readBytes(bytes);
        // 生成和初始化消息包装类
        String ip = ((InetSocketAddress) ctx.channel().remoteAddress()).getAddress().getHostAddress();
@@ -42,8 +36,12 @@
        pac.setSourceBuff(in);
        pac.setBytes(bytes);
        list.add(pac);
        // 解析
        list.add(analyzeProtocol(pac));
//        list.add(analyzeProtocol(pac));
    }
    public ChPackage analyzeProtocol(ChPackage pac){