1、服务端部分代码重构
2、流量报表字段调整 3、增加流量统计相关逻辑
This commit is contained in:
+3
-3
@@ -42,15 +42,15 @@ public class RealServerChannelHandler extends SimpleChannelInboundHandler<ByteBu
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf buf) throws Exception {
|
||||
Channel realServerChannel = ctx.channel();
|
||||
Channel channel = realServerChannel.attr(Constants.NEXT_CHANNEL).get();
|
||||
if (channel == null) {
|
||||
Channel proxyChannel = realServerChannel.attr(Constants.NEXT_CHANNEL).get();
|
||||
if (null == proxyChannel) {
|
||||
// 代理客户端连接断开
|
||||
ctx.channel().close();
|
||||
} else {
|
||||
byte[] bytes = new byte[buf.readableBytes()];
|
||||
buf.readBytes(bytes);
|
||||
String visitorId = ProxyUtil.getVisitorIdByRealServerChannel(realServerChannel);
|
||||
channel.writeAndFlush(ProxyMessage.buildTransferMessage(visitorId, bytes));
|
||||
proxyChannel.writeAndFlush(ProxyMessage.buildTransferMessage(visitorId, bytes));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user