Browse Source

/*打印下行报文16进制字符串*/

master
htjcAdmin 2 months ago
parent
commit
cecb26dd00
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      src/main/java/com/inspect/tcpserver/tcp/NettyServerHandler.java

+ 6
- 0
src/main/java/com/inspect/tcpserver/tcp/NettyServerHandler.java View File

@ -2,6 +2,7 @@ package com.inspect.tcpserver.tcp;
import com.inspect.tcpserver.util.Color;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext;
@ -22,6 +23,11 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
public void sendMsg(String uuid, String clientKey, ByteBuf byteBuf, String xml, boolean request) {
ChannelHandlerContext ctx = ChannelCache.getInstance().get(clientKey);
if(ctx != null) {
// 打印下行报文
ByteBuf forPrint = byteBuf.copy();
log.info("WRITE_AND_FLUSH SESSION :{}, CLIENT: {}, HEX: {}", uuid, ctx.channel().id().asShortText(), ByteBufUtil.hexDump(forPrint));
forPrint.release();
ctx.writeAndFlush(Unpooled.wrappedBuffer(byteBuf)).addListener(
(ChannelFuture future) -> {
if (future.isSuccess()) {


Loading…
Cancel
Save