Helius
2021-05-27 0792c2a65171eb7a763ac74cd4546552b7e0c756
src/main/java/com/xcong/excoin/netty/logic/WebSocketLogic.java
@@ -76,10 +76,12 @@
    public void sendMsg(RequestBean requestBean) {
        String chatStr = requestBean.getData().toString();
        log.info("接收到的消息:{}", chatStr);
        ChatRequest chat = JSONObject.parseObject(chatStr, ChatRequest.class);
        Channel channel = ChannelManager.findWebSocketChannel(requestBean.getChannelId());
        ResponseBean res = ResponseBean.ok(chat);
        chat.setTimestamp(System.currentTimeMillis());
        res.setType(2);
        channel.writeAndFlush(NettyTools.webSocketJson(res));
@@ -90,8 +92,6 @@
            ResponseBean toRes = ResponseBean.ok(chat);
            res.setType(2);
            targetChannel.writeAndFlush(NettyTools.webSocketJson(toRes));
            chatProducer.sendMsgHistory(chat);
        } else {
            // 在redis中保存用户未在线时,给该用户发送的消息条数
            String key = AppContants.MSG_NOTICE + chat.getTargetId();
@@ -102,5 +102,6 @@
                redisUtils.set(key, Integer.parseInt(value) + 1);
            }
        }
        chatProducer.sendMsgHistory(chat);
    }
}