09-16-01
This commit is contained in:
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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 = "我是服务器,这里发送的是群消息";
|
||||||
|
|||||||
Reference in New Issue
Block a user