| | |
| | | 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(); |
| | |
| | | |
| | | pac.setSourceBuff(in); |
| | | |
| | | pac.setBytes(bytes); |
| | | |
| | | list.add(pac); |
| | | |
| | | // 解析 |
| | | list.add(analyzeProtocol(pac)); |
| | | // list.add(analyzeProtocol(pac)); |
| | | } |
| | | |
| | | public ChPackage analyzeProtocol(ChPackage pac){ |