正在显示
4 个修改的文件
包含
11 行增加
和
8 行删除
| @@ -62,8 +62,9 @@ public class RouteController { | @@ -62,8 +62,9 @@ public class RouteController { | ||
| 62 | 62 | ||
| 63 | //推送消息 | 63 | //推送消息 |
| 64 | String url = "http://" + value.getIp() + ":" + value.getHttpPort() + "/sendMsg" ; | 64 | String url = "http://" + value.getIp() + ":" + value.getHttpPort() + "/sendMsg" ; |
| 65 | - ChatReqVO vo = new ChatReqVO(userId,groupReqVO.getMsg()) ; | ||
| 66 | - accountService.pushMsg(url,vo); | 65 | + ChatReqVO chatVO = new ChatReqVO(userId,groupReqVO.getMsg()) ; |
| 66 | + | ||
| 67 | + accountService.pushMsg(url,groupReqVO.getUserId(),chatVO); | ||
| 67 | 68 | ||
| 68 | } | 69 | } |
| 69 | 70 |
| @@ -51,9 +51,10 @@ public interface AccountService { | @@ -51,9 +51,10 @@ public interface AccountService { | ||
| 51 | * 推送消息 | 51 | * 推送消息 |
| 52 | * @param url url | 52 | * @param url url |
| 53 | * @param groupReqVO 消息 | 53 | * @param groupReqVO 消息 |
| 54 | + * @param sendUserId 发送者的ID | ||
| 54 | * @throws Exception | 55 | * @throws Exception |
| 55 | */ | 56 | */ |
| 56 | - void pushMsg(String url,ChatReqVO groupReqVO) throws Exception; | 57 | + void pushMsg(String url,long sendUserId ,ChatReqVO groupReqVO) throws Exception; |
| 57 | 58 | ||
| 58 | /** | 59 | /** |
| 59 | * 用户下线 | 60 | * 用户下线 |
cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/AccountServiceRedisImpl.java
| @@ -113,13 +113,13 @@ public class AccountServiceRedisImpl implements AccountService { | @@ -113,13 +113,13 @@ public class AccountServiceRedisImpl implements AccountService { | ||
| 113 | 113 | ||
| 114 | 114 | ||
| 115 | @Override | 115 | @Override |
| 116 | - public void pushMsg(String url, ChatReqVO groupReqVO) throws Exception { | ||
| 117 | - Long userId = groupReqVO.getUserId(); | ||
| 118 | - String userName = redisTemplate.opsForValue().get(ACCOUNT_PREFIX + userId); | 116 | + public void pushMsg(String url, long sendUserId, ChatReqVO groupReqVO) throws Exception { |
| 117 | + //可考虑本地缓存 | ||
| 118 | + String sendUserName = redisTemplate.opsForValue().get(ACCOUNT_PREFIX + sendUserId); | ||
| 119 | 119 | ||
| 120 | JSONObject jsonObject = new JSONObject(); | 120 | JSONObject jsonObject = new JSONObject(); |
| 121 | - jsonObject.put("msg", userName + ":【" + groupReqVO.getMsg() + "】"); | ||
| 122 | - jsonObject.put("userId", userId); | 121 | + jsonObject.put("msg", sendUserName + ":【" + groupReqVO.getMsg() + "】"); |
| 122 | + jsonObject.put("userId", groupReqVO.getUserId()); | ||
| 123 | RequestBody requestBody = RequestBody.create(mediaType, jsonObject.toString()); | 123 | RequestBody requestBody = RequestBody.create(mediaType, jsonObject.toString()); |
| 124 | 124 | ||
| 125 | Request request = new Request.Builder() | 125 | Request request = new Request.Builder() |
| @@ -55,6 +55,7 @@ public class CIMServerHandle extends SimpleChannelInboundHandler<CIMRequestProto | @@ -55,6 +55,7 @@ public class CIMServerHandle extends SimpleChannelInboundHandler<CIMRequestProto | ||
| 55 | AppConfiguration configuration = SpringBeanFactory.getBean(AppConfiguration.class); | 55 | AppConfiguration configuration = SpringBeanFactory.getBean(AppConfiguration.class); |
| 56 | JSONObject jsonObject = new JSONObject(); | 56 | JSONObject jsonObject = new JSONObject(); |
| 57 | jsonObject.put("userId", userInfo.getUserId()); | 57 | jsonObject.put("userId", userInfo.getUserId()); |
| 58 | + jsonObject.put("msg", "offLine"); | ||
| 58 | RequestBody requestBody = RequestBody.create(mediaType, jsonObject.toString()); | 59 | RequestBody requestBody = RequestBody.create(mediaType, jsonObject.toString()); |
| 59 | 60 | ||
| 60 | Request request = new Request.Builder() | 61 | Request request = new Request.Builder() |
-
请 注册 或 登录 后发表评论