|
|
|
@ -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()) { |
|
|
|
|