mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-03 05:20:50 +00:00
pref[net]:解码修改
This commit is contained in:
1 parent
2222a56e8c
commit
382f214ec7
2 files changed
+9
-8
No files matched your search
@@ -52,9 +52,8 @@ public class TcpPacketCodecHandler extends ByteToMessageCodec<EncodedPacketInfo>
|
||||
|
||||
// 如果长度非法,则抛出异常断开连接
|
||||
if (length < 0) {
|
||||
throw new IllegalArgumentException(StringUtils
|
||||
.format("[session:{}]的包头长度[length:{}]非法"
|
||||
, SessionUtils.sessionInfo(ctx), length));
|
||||
throw new IllegalArgumentException(StringUtils.format("[session:{}]的包头长度[length:{}]非法"
|
||||
, SessionUtils.sessionInfo(ctx), length));
|
||||
}
|
||||
|
||||
// ByteBuf里的数据太小
|
||||
@@ -63,8 +62,9 @@ public class TcpPacketCodecHandler extends ByteToMessageCodec<EncodedPacketInfo>
|
||||
return;
|
||||
}
|
||||
|
||||
var tmpByteBuf = in.readRetainedSlice(length);
|
||||
ByteBuf tmpByteBuf = null;
|
||||
try {
|
||||
tmpByteBuf = in.readRetainedSlice(length);
|
||||
DecodedPacketInfo packetInfo = NetContext.getPacketService().read(tmpByteBuf);
|
||||
out.add(packetInfo);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -60,9 +60,8 @@ public class WebSocketCodecHandler extends MessageToMessageCodec<WebSocketFrame,
|
||||
|
||||
// 如果长度非法,则抛出异常断开连接
|
||||
if (length < 0) {
|
||||
throw new IllegalArgumentException(StringUtils
|
||||
.format("[session:{}]的包头长度[length:{}]非法"
|
||||
, SessionUtils.sessionInfo(channelHandlerContext), length));
|
||||
throw new IllegalArgumentException(StringUtils.format("[session:{}]的包头长度[length:{}]非法"
|
||||
, SessionUtils.sessionInfo(channelHandlerContext), length));
|
||||
}
|
||||
|
||||
// ByteBuf里的数据太小
|
||||
@@ -70,8 +69,10 @@ public class WebSocketCodecHandler extends MessageToMessageCodec<WebSocketFrame,
|
||||
in.resetReaderIndex();
|
||||
return;
|
||||
}
|
||||
var tmpByteBuf = in.readRetainedSlice(length);
|
||||
|
||||
ByteBuf tmpByteBuf = null;
|
||||
try {
|
||||
tmpByteBuf = in.readRetainedSlice(length);
|
||||
DecodedPacketInfo packetInfo = NetContext.getPacketService().read(tmpByteBuf);
|
||||
list.add(packetInfo);
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in new issue
Block a user