From d2314059892561c4d9f89264db43cf92d741eb42 Mon Sep 17 00:00:00 2001 From: zwl <1051256694@qq.com> Date: 星期四, 26 六月 2025 15:05:08 +0800 Subject: [PATCH] 完善待测 --- src/main/java/com/zy/core/netty/handle/ProtocolDecoder.java | 14 +++----------- 1 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/zy/core/netty/handle/ProtocolDecoder.java b/src/main/java/com/zy/core/netty/handle/ProtocolDecoder.java index 7cb12d7..4b9cdeb 100644 --- a/src/main/java/com/zy/core/netty/handle/ProtocolDecoder.java +++ b/src/main/java/com/zy/core/netty/handle/ProtocolDecoder.java @@ -7,6 +7,7 @@ import io.netty.buffer.ByteBufUtil; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ByteToMessageDecoder; +import lombok.extern.slf4j.Slf4j; import java.net.InetSocketAddress; import java.nio.charset.StandardCharsets; @@ -15,6 +16,7 @@ /** * Created by vincent on 2019-04-10 */ +@Slf4j public class ProtocolDecoder extends ByteToMessageDecoder { private final SnowflakeIdWorker snowflakeIdWorker; @@ -23,20 +25,10 @@ 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(); - } - // 鐢熸垚鍜屽垵濮嬪寲娑堟伅鍖呰绫� + // 鐢熸垚鍜屽垵濮嬪寲娑堟伅鍖呰绫� String ip = ((InetSocketAddress) ctx.channel().remoteAddress()).getAddress().getHostAddress(); ChPackage pac = ChPackage.valueOfEmpty(String.valueOf(snowflakeIdWorker.nextId()), ip); -- Gitblit v1.9.1