From 9efa9a5bc1c36a7061a909ff9d315b9e616876ef Mon Sep 17 00:00:00 2001
From: 18516761980 <56479841@qq.com>
Date: 星期六, 30 七月 2022 12:42:19 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/netty/handle/ProtocolDecoder.java |   20 +++++++++-----------
 1 files changed, 9 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..c265083 100644
--- a/src/main/java/com/zy/core/netty/handle/ProtocolDecoder.java
+++ b/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);
+
         // 瑙f瀽
-        list.add(analyzeProtocol(pac));
+//        list.add(analyzeProtocol(pac));
     }
 
     public ChPackage analyzeProtocol(ChPackage pac){

--
Gitblit v1.9.1