Showing
1 changed file
with
3 additions
and
1 deletions
@@ -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, |