This commit is contained in:
2025-09-16 21:31:12 +08:00
parent 579fd04687
commit b2ec975f22
2 changed files with 6 additions and 5 deletions

View File

@ -68,12 +68,12 @@ public class ChatServer {
}); });
log.info("Netty聊天服务器启动端口" + port); log.info("Netty聊天服务器启动端口" + port);
// bootstrap.bind(port).sync(); bootstrap.bind(port).sync();
ChannelFuture future = bootstrap.bind(port).sync(); // ChannelFuture future = bootstrap.bind(port).sync();
future.channel().closeFuture().sync(); // future.channel().closeFuture().sync();
} finally { } finally {
workerGroup.shutdownGracefully().sync(); // workerGroup.shutdownGracefully().sync();
bossGroup.shutdownGracefully().sync(); // bossGroup.shutdownGracefully().sync();
} }
} }

View File

@ -441,6 +441,7 @@ public class ChatServerHandler extends SimpleChannelInboundHandler<TextWebSocket
ctx.channel().writeAndFlush(new TextWebSocketFrame(message)); ctx.channel().writeAndFlush(new TextWebSocketFrame(message));
} }
//发送群消息,此时其他客户端也能收到群消息 //发送群消息,此时其他客户端也能收到群消息
private void sendAllMessage(){ private void sendAllMessage(){
String message = "我是服务器,这里发送的是群消息"; String message = "我是服务器,这里发送的是群消息";