Commit 255e2a9f authored by duanruiming's avatar duanruiming

[update] 代码优化

parent 89c4716b
......@@ -48,15 +48,15 @@ public class NettyClient {
.handler(new ChannelInitializer<NioSocketChannel>() {
@Override
protected void initChannel(NioSocketChannel socketChannel) {
log.info("新增客户端连接ip:{},port:{}", socketChannel.remoteAddress().getHostString(), socketChannel.remoteAddress().getPort());
socketChannel.writeAndFlush("2a320d0a24340d0a415554480d0a2431360d0a536d2a674234504742333939514241390d0a");
log.info("发送密码。。。");
socketChannel.pipeline()
.addLast(new LengthFieldBasedFrameDecoder(ByteOrder.LITTLE_ENDIAN, Integer.MAX_VALUE, 4, 2, 0, 0, true))
.addLast(new NettyServerHandler(threadPoolExecutor));
channelGroup.add(socketChannel);
String key = StringUtils.join(socketChannel.remoteAddress().getHostString(), ":".intern(), socketChannel.remoteAddress().getPort());
IP_PORT_CHANNEL_ID_MAP.put(key, socketChannel.id());
String str = "2a320d0a24340d0a415554480d0a2431360d0a536d2a674234504742333939514241390d0a";
MessageResultPojo resultPojo = NettyClient.sendMessage("10.102.1.204", 5050, str, "80", 300);
log.info("信号返回字符串:{}", resultPojo);
log.info("{}:客户端连接成功", key);
}
});
......
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