| | |
| | | System.out.println("客户端断开连接:" + ctx.channel()); |
| | | //用户离线状态 |
| | | String name = ChannelSupervise.findName(ctx.channel().id().asShortText()); |
| | | System.out.println(name); |
| | | if ( name != null &&!name.equals("ping") ){ |
| | | NettyConfig.getChannelGroup().remove(ctx.channel()); |
| | | removeUserId(ctx); |
| | |
| | | //登录链接 |
| | | String id = jsonObj.get("id").toString(); |
| | | NettyConfig.getUserChannelMap().put(id,ctx.channel()); |
| | | NettyConfig.getChannelGroup().add(ctx.channel()); |
| | | |
| | | System.out.println(jsonObj.get("type")); |
| | | System.out.println(jsonObj.get("id")); |
| | | System.out.println("___________________"+jsonObj.get("type")); |
| | | System.out.println(jsonObj.get("id")+ "____________________________用户连接成功"); |
| | | |
| | | //将用户id作为自定义属性加入到channel 中,方便随时channel中获取用户id |
| | | AttributeKey<String> key = AttributeKey.valueOf("userId"); |
| | |
| | | //把用户信息添加到通道里 |
| | | ChannelSupervise.addChannel(ctx.channel(),id); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |