|
@@ -23,7 +23,7 @@ public class NioWebSocketHandler extends SimpleChannelInboundHandler<Object> {
|
|
|
|
|
|
@Override
|
|
|
protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
|
|
- //log.info("收到消息" + msg);
|
|
|
+ log.info("收到消息" + msg);
|
|
|
if (msg instanceof FullHttpRequest) {
|
|
|
//以http请求形式接入,但是走的是websocket
|
|
|
handleHttpRequest(ctx, (FullHttpRequest) msg);
|
|
@@ -44,7 +44,7 @@ public class NioWebSocketHandler extends SimpleChannelInboundHandler<Object> {
|
|
|
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
|
|
//断开连接
|
|
|
log.info("客户端断开连接:" + ctx.channel());
|
|
|
- ChannelManage.removeChannel(ctx.channel());
|
|
|
+ com.jd.cms.nettySocket.ChannelManage.removeChannel(ctx.channel());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -76,7 +76,7 @@ public class NioWebSocketHandler extends SimpleChannelInboundHandler<Object> {
|
|
|
.set("msg", request);
|
|
|
TextWebSocketFrame tws = new TextWebSocketFrame(msg.toString());
|
|
|
// 群发,把当前通道传过去,那边排除掉
|
|
|
- ChannelManage.send2All(tws, ctx.channel().id());
|
|
|
+ com.jd.cms.nettySocket.ChannelManage.send2All(tws, ctx.channel().id());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -90,7 +90,7 @@ public class NioWebSocketHandler extends SimpleChannelInboundHandler<Object> {
|
|
|
return;
|
|
|
}
|
|
|
//WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory("ws://192.168.0.114:8088/websocket", null, true);
|
|
|
- handshaker = new WebSocketServerHandshaker13("ws://23.37.100.81:8088/websocket", null, true, 1024 * 1024 * 6);
|
|
|
+ handshaker = new WebSocketServerHandshaker13("ws://23.37.100.81:8111/websocket", null, true, 1024 * 1024 * 6);
|
|
|
if (handshaker == null) {
|
|
|
WebSocketServerHandshakerFactory.sendUnsupportedVersionResponse(ctx.channel());
|
|
|
} else {
|