| | |
| | | public static TextWebSocketFrame webSocketBytes(String msg) { |
| | | return new TextWebSocketFrame(msg); |
| | | } |
| | | |
| | | public static TextWebSocketFrame webSocketJson(Object object) { |
| | | return webSocketBytes(JSONObject.toJSONString(object)); |
| | | } |
| | | } |
| | |
| | | String chatStr = requestBean.getData().toString(); |
| | | ChatRequest chat = JSONObject.parseObject(chatStr, ChatRequest.class); |
| | | |
| | | Channel channel = ChannelManager.findWebSocketChannel(requestBean.getChannelId()); |
| | | channel.writeAndFlush(NettyTools.webSocketJson(ResponseBean.ok(chat))); |
| | | // 判断是否在线 |
| | | Channel targetChannel = ChannelManager.findWsChannel(Long.parseLong(chat.getTo())); |
| | | if (targetChannel != null) { |