[fix] channel with no clientId

This commit is contained in:
wujiawei 2024-01-17 16:25:58 +08:00
parent 62ecd2f987
commit 8f904cf1b0

View File

@ -105,10 +105,13 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<NettyProxyMs
String clientId = ChannelAttributeKeyUtils.getClientId(channel);
log.info("断开客户端的连接:{}", clientId);
NettyProxyMsg nettyMsg = new NettyProxyMsg();
nettyMsg.setType(MessageType.REPORT_CLIENT_DISCONNECTION);
nettyMsg.setClientId(clientId);
channelTypeAdapter.handler(channel, nettyMsg);
super.channelInactive(ctx);
if (!ObjectUtils.isEmpty(clientId)) {
NettyProxyMsg nettyMsg = new NettyProxyMsg();
nettyMsg.setType(MessageType.REPORT_CLIENT_DISCONNECTION);
nettyMsg.setClientId(clientId);
channelTypeAdapter.handler(channel, nettyMsg);
super.channelInactive(ctx);
}
}
}