From dfba2527779964851703030485e95e4a543df8eb Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Thu, 27 May 2021 16:20:33 +0800 Subject: [PATCH] modify --- src/main/java/com/xcong/excoin/netty/logic/WebSocketLogic.java | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/src/main/java/com/xcong/excoin/netty/logic/WebSocketLogic.java b/src/main/java/com/xcong/excoin/netty/logic/WebSocketLogic.java index f1034c8..44751e1 100644 --- a/src/main/java/com/xcong/excoin/netty/logic/WebSocketLogic.java +++ b/src/main/java/com/xcong/excoin/netty/logic/WebSocketLogic.java @@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject; import com.xcong.excoin.common.contants.AppContants; import com.xcong.excoin.configurations.properties.SecurityProperties; +import com.xcong.excoin.modules.member.entity.MemberEntity; import com.xcong.excoin.netty.bean.ChatRequest; import com.xcong.excoin.netty.bean.RequestBean; import com.xcong.excoin.netty.bean.ResponseBean; @@ -48,8 +49,18 @@ // // Long memberId = Long.parseLong(tokens[0]); + String token = requestBean.getData().toString(); + String redisKey = AppContants.APP_LOGIN_PREFIX + token; + String loginStr = redisUtils.getString(redisKey); + if (StrUtil.isBlank(loginStr)) { + ResponseBean res = ResponseBean.fail(); + res.setType(requestBean.getType()); + channel.writeAndFlush(NettyTools.webSocketBytes(JSONObject.toJSONString(res))); + return; + } - Long memberId = Long.parseLong(requestBean.getData().toString()); + MemberEntity loginUser = JSONObject.parseObject(loginStr, MemberEntity.class); + Long memberId = loginUser.getId(); channel.writeAndFlush(NettyTools.webSocketBytes(JSONObject.toJSONString(responseBean))); ChannelManager.addWsChannel(channel, memberId); -- Gitblit v1.9.1