diff --git a/nettyPro/src/main/java/cn/zyjblogs/netty/protocoltcp/MyClientHandler.java b/nettyPro/src/main/java/cn/zyjblogs/netty/protocoltcp/MyClientHandler.java index 74d7cf2..70aa2f8 100644 --- a/nettyPro/src/main/java/cn/zyjblogs/netty/protocoltcp/MyClientHandler.java +++ b/nettyPro/src/main/java/cn/zyjblogs/netty/protocoltcp/MyClientHandler.java @@ -19,7 +19,10 @@ public class MyClientHandler extends SimpleChannelInboundHandler { @Override protected void encode(ChannelHandlerContext ctx, MessageProtocol msg, ByteBuf out) throws Exception { - System.out.println("MyMessageEncoder方法被调用 编码"); + System.out.println("\nMyMessageEncoder方法被调用 编码"); out.writeInt(msg.getLen()); out.writeBytes(msg.getContent()); } diff --git a/nettyPro/src/main/java/cn/zyjblogs/netty/protocoltcp/MyServerHandler.java b/nettyPro/src/main/java/cn/zyjblogs/netty/protocoltcp/MyServerHandler.java index c34b4fd..6b262db 100644 --- a/nettyPro/src/main/java/cn/zyjblogs/netty/protocoltcp/MyServerHandler.java +++ b/nettyPro/src/main/java/cn/zyjblogs/netty/protocoltcp/MyServerHandler.java @@ -7,6 +7,7 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.util.CharsetUtil; +import java.nio.charset.StandardCharsets; import java.util.UUID; public class MyServerHandler extends SimpleChannelInboundHandler { @@ -20,9 +21,19 @@ public class MyServerHandler extends SimpleChannelInboundHandler