作者 crossoverJie

:recycle: Refactoring code.联调成功 群发

... ... @@ -62,8 +62,9 @@ public class RouteController {
//推送消息
String url = "http://" + value.getIp() + ":" + value.getHttpPort() + "/sendMsg" ;
ChatReqVO vo = new ChatReqVO(userId,groupReqVO.getMsg()) ;
accountService.pushMsg(url,vo);
ChatReqVO chatVO = new ChatReqVO(userId,groupReqVO.getMsg()) ;
accountService.pushMsg(url,groupReqVO.getUserId(),chatVO);
}
... ...
... ... @@ -51,9 +51,10 @@ public interface AccountService {
* 推送消息
* @param url url
* @param groupReqVO 消息
* @param sendUserId 发送者的ID
* @throws Exception
*/
void pushMsg(String url,ChatReqVO groupReqVO) throws Exception;
void pushMsg(String url,long sendUserId ,ChatReqVO groupReqVO) throws Exception;
/**
* 用户下线
... ...
... ... @@ -113,13 +113,13 @@ public class AccountServiceRedisImpl implements AccountService {
@Override
public void pushMsg(String url, ChatReqVO groupReqVO) throws Exception {
Long userId = groupReqVO.getUserId();
String userName = redisTemplate.opsForValue().get(ACCOUNT_PREFIX + userId);
public void pushMsg(String url, long sendUserId, ChatReqVO groupReqVO) throws Exception {
//可考虑本地缓存
String sendUserName = redisTemplate.opsForValue().get(ACCOUNT_PREFIX + sendUserId);
JSONObject jsonObject = new JSONObject();
jsonObject.put("msg", userName + ":【" + groupReqVO.getMsg() + "】");
jsonObject.put("userId", userId);
jsonObject.put("msg", sendUserName + ":【" + groupReqVO.getMsg() + "】");
jsonObject.put("userId", groupReqVO.getUserId());
RequestBody requestBody = RequestBody.create(mediaType, jsonObject.toString());
Request request = new Request.Builder()
... ...
... ... @@ -55,6 +55,7 @@ public class CIMServerHandle extends SimpleChannelInboundHandler<CIMRequestProto
AppConfiguration configuration = SpringBeanFactory.getBean(AppConfiguration.class);
JSONObject jsonObject = new JSONObject();
jsonObject.put("userId", userInfo.getUserId());
jsonObject.put("msg", "offLine");
RequestBody requestBody = RequestBody.create(mediaType, jsonObject.toString());
Request request = new Request.Builder()
... ...