From 8b6c03b3f14f1e140c2ab694f1e2a3bbc123d7f4 Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期六, 13 八月 2022 16:32:32 +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