Helius
2021-05-27 9a968ba186af5280fcc29cc3eb04412eff204ba7
modify
2 files modified
6 ■■■■■ changed files
src/main/java/com/xcong/excoin/netty/common/NettyTools.java 4 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/netty/logic/WebSocketLogic.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/netty/common/NettyTools.java
@@ -31,4 +31,8 @@
    public static TextWebSocketFrame webSocketBytes(String msg) {
        return new TextWebSocketFrame(msg);
    }
    public static TextWebSocketFrame webSocketJson(Object object) {
        return webSocketBytes(JSONObject.toJSONString(object));
    }
}
src/main/java/com/xcong/excoin/netty/logic/WebSocketLogic.java
@@ -78,6 +78,8 @@
        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) {