Commit 82532620 authored by duanruiming's avatar duanruiming

[update] channel缓存

parent 7ec46126
...@@ -45,6 +45,9 @@ public class NettyServer { ...@@ -45,6 +45,9 @@ public class NettyServer {
protected void initChannel(NioDatagramChannel datagramChannel) { protected void initChannel(NioDatagramChannel datagramChannel) {
datagramChannel.pipeline() datagramChannel.pipeline()
.addLast(new NettyServerHandler(threadPoolExecutor)); .addLast(new NettyServerHandler(threadPoolExecutor));
String key = StringUtils.join(datagramChannel.remoteAddress().getHostString(), ":".intern(), datagramChannel.remoteAddress().getPort());
log.info("client {} is connect success", key);
IP_PORT_CHANNEL_ID_MAP.put(key, datagramChannel.id());
} }
}); });
ChannelFuture channelFuture = bootstrap.bind(port).sync(); ChannelFuture channelFuture = bootstrap.bind(port).sync();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment