Commit 50a8f74e73ead1a1217d718490904fa1ae736565

Authored by lijianfa_14810364212
1 parent 9fb13737

fix:解决TCP设备特殊字符密码不能连接的问题

@@ -17,6 +17,8 @@ import io.netty.channel.ChannelHandlerContext; @@ -17,6 +17,8 @@ import io.netty.channel.ChannelHandlerContext;
17 import io.netty.channel.ChannelInboundHandlerAdapter; 17 import io.netty.channel.ChannelInboundHandlerAdapter;
18 import io.netty.util.ReferenceCountUtil; 18 import io.netty.util.ReferenceCountUtil;
19 import java.net.InetSocketAddress; 19 import java.net.InetSocketAddress;
  20 +import java.nio.ByteBuffer;
  21 +import java.nio.charset.StandardCharsets;
20 import java.util.*; 22 import java.util.*;
21 23
22 import io.netty.util.concurrent.Future; 24 import io.netty.util.concurrent.Future;
@@ -79,7 +81,7 @@ public class TcpTransportHandler extends ChannelInboundHandlerAdapter implements @@ -79,7 +81,7 @@ public class TcpTransportHandler extends ChannelInboundHandlerAdapter implements
79 if (msg instanceof ByteBuf) { 81 if (msg instanceof ByteBuf) {
80 ByteBuf message = (ByteBuf) msg; 82 ByteBuf message = (ByteBuf) msg;
81 byte[] byteMsg = ByteBufUtils.buf2Bytes(message); 83 byte[] byteMsg = ByteBufUtils.buf2Bytes(message);
82 - String msgStr = ByteUtils.bytesToStr(byteMsg); 84 + String msgStr = StandardCharsets.UTF_8.decode(ByteBuffer.wrap(byteMsg)).toString();
83 log.debug( 85 log.debug(
84 "TCP服务【{}】收到设备【{}】来自【{}】数据【{}】", 86 "TCP服务【{}】收到设备【{}】来自【{}】数据【{}】",
85 sessionId, 87 sessionId,