部分代码优化

This commit is contained in:
aoshiguchen
2022-10-23 13:53:54 +08:00
parent f71055b6ea
commit 4b8ec0b33b
5 changed files with 10 additions and 11 deletions
@@ -63,8 +63,8 @@ public class VisitorChannelHandler extends SimpleChannelInboundHandler<ByteBuf>
} else {
byte[] bytes = new byte[buf.readableBytes()];
buf.readBytes(bytes);
String userId = ProxyUtil.getVisitorChannelUserId(visitorChannel);
proxyChannel.writeAndFlush(ProxyMessage.buildTransferMessage(userId, bytes));
String visitorId = ProxyUtil.getVisitorIdByChannel(visitorChannel);
proxyChannel.writeAndFlush(ProxyMessage.buildTransferMessage(visitorId, bytes));
}
}
@@ -104,7 +104,7 @@ public class VisitorChannelHandler extends SimpleChannelInboundHandler<ByteBuf>
} else {
// 用户连接断开,从控制连接中移除
String userId = ProxyUtil.getVisitorChannelUserId(userChannel);
String userId = ProxyUtil.getVisitorIdByChannel(userChannel);
ProxyUtil.removeVisitorChannelFromCmdChannel(cmdChannel, userId);
Channel proxyChannel = userChannel.attr(Constants.NEXT_CHANNEL).get();
@@ -217,12 +217,12 @@ public class ProxyUtil {
}
/**
* 获取用户编号
* 获取访问者ID
*
* @param visitorChannel
* @return
*/
public static String getVisitorChannelUserId(Channel visitorChannel) {
public static String getVisitorIdByChannel(Channel visitorChannel) {
if (null == visitorChannel || null == getAttachInfo(visitorChannel)) {
return null;
}