socket通讯调整

This commit is contained in:
2025-06-19 14:33:28 +08:00
parent d26504c841
commit 977ab4bf1b

View File

@@ -73,13 +73,10 @@ public class NettyClient {
channelFuture.addListener((ChannelFutureListener) ch -> {
if (!ch.isSuccess()) {
System.out.println("链接服务端失败...");
// 连接失败时关闭 group
group.shutdownGracefully();
} else {
System.out.println("链接服务端成功...");
System.out.println("客户端向服务端发送消息:" + port + msg);
channelFuture.channel().writeAndFlush(msg + "\n").sync();
}
});
if (handler instanceof NettySourceClientHandler) {
NioEventLoopGroup groupByUserId = SocketManager.getGroupByUserId(param.getUserPageId() + source);
if(ObjectUtil.isNotNull(groupByUserId)){
@@ -94,8 +91,10 @@ public class NettyClient {
SocketManager.addGroup(param.getUserPageId() + dev, group);
}
System.out.println("客户端向服务端发送消息:" + port + msg);
channelFuture.channel().writeAndFlush(msg + "\n");
}
});
} catch (Exception e) {
System.out.println("连接socket服务端发送异常............" + e.getMessage());
group.shutdownGracefully();