|
|
@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
|
|
|
|
|
import io.netty.buffer.ByteBuf; |
|
|
|
import io.netty.buffer.ByteBuf; |
|
|
|
import io.netty.channel.Channel; |
|
|
|
import io.netty.channel.Channel; |
|
|
|
|
|
|
|
import io.netty.channel.ChannelFutureListener; |
|
|
|
import io.netty.channel.ChannelHandlerContext; |
|
|
|
import io.netty.channel.ChannelHandlerContext; |
|
|
|
import io.netty.channel.SimpleChannelInboundHandler; |
|
|
|
import io.netty.channel.SimpleChannelInboundHandler; |
|
|
|
|
|
|
|
|
|
|
@ -74,7 +75,9 @@ public class ServerChannelHandler extends SimpleChannelInboundHandler<ProxyMessa |
|
|
|
String userId = proxyMessage.getUri(); |
|
|
|
String userId = proxyMessage.getUri(); |
|
|
|
Channel userChannel = ProxyChannelManager.removeUserChannel(ctx.channel(), userId); |
|
|
|
Channel userChannel = ProxyChannelManager.removeUserChannel(ctx.channel(), userId); |
|
|
|
if (userChannel != null) { |
|
|
|
if (userChannel != null) { |
|
|
|
userChannel.close(); |
|
|
|
// 数据发送完成后再关闭连接,解决http1.0数据传输问题
|
|
|
|
|
|
|
|
ByteBuf buf = ctx.alloc().buffer(0); |
|
|
|
|
|
|
|
userChannel.writeAndFlush(buf).addListener(ChannelFutureListener.CLOSE); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|