Commit 785db346 by JJww

Merge branch 'Jw' into 'master'

新增USER_DEVICE_PUSH_TOKEN 保存用户对应的Push信息 减少每次发送查询token

See merge request hewei/Jumeirah!68
parents a990becd df05398c
...@@ -24,8 +24,6 @@ public class UserSocketInfo extends BaseSocketInfo { ...@@ -24,8 +24,6 @@ public class UserSocketInfo extends BaseSocketInfo {
private Set<Long> sessionList; private Set<Long> sessionList;
private DeviceTokenParam deviceTokenParam;
private Map<Long, Long> staffIds = new HashMap<>(); private Map<Long, Long> staffIds = new HashMap<>();
public Long getStaffId(Long merchantId) { public Long getStaffId(Long merchantId) {
......
package com.ym.im.handler; package com.ym.im.handler;
import com.ym.im.entity.DeviceTokenParam;
import com.ym.im.entity.StaffSocketInfo; import com.ym.im.entity.StaffSocketInfo;
import com.ym.im.entity.UserSocketInfo; import com.ym.im.entity.UserSocketInfo;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -25,6 +26,11 @@ public class ChannelGroupHandler { ...@@ -25,6 +26,11 @@ public class ChannelGroupHandler {
*/ */
public final Map<Long, Map<Long, StaffSocketInfo>> STAFF_GROUP = new ConcurrentHashMap<>(); public final Map<Long, Map<Long, StaffSocketInfo>> STAFF_GROUP = new ConcurrentHashMap<>();
/**
* 用户推送tokenGroup
*/
public final Map<Long, DeviceTokenParam> USER_DEVICE_PUSH_TOKEN = new ConcurrentHashMap<>();
/** /**
* 新增商户 客服 * 新增商户 客服
......
...@@ -181,11 +181,9 @@ public class StaffSingleChatServiceImpl implements ChatService { ...@@ -181,11 +181,9 @@ public class StaffSingleChatServiceImpl implements ChatService {
*/ */
@SneakyThrows @SneakyThrows
private void pushNotifications(Long userId) { private void pushNotifications(Long userId) {
final UserSocketInfo userSocketInfo = channelGroup.USER_GROUP.get(userId); final DeviceTokenParam deviceTokenParam = channelGroup.USER_DEVICE_PUSH_TOKEN.get(userId);
if (userSocketInfo != null) {
final DeviceTokenParam deviceTokenParam = userSocketInfo.getDeviceTokenParam();
pushFactory.getService(deviceTokenParam.getDeviceType()).unicast(deviceTokenParam.getDeviceToken()); pushFactory.getService(deviceTokenParam.getDeviceType()).unicast(deviceTokenParam.getDeviceToken());
}
} }
......
...@@ -76,8 +76,8 @@ public class UserSingleChatServiceImpl implements ChatService { ...@@ -76,8 +76,8 @@ public class UserSingleChatServiceImpl implements ChatService {
Map<String, String> headers = new HashMap<>(); Map<String, String> headers = new HashMap<>();
headers.put("token", token); headers.put("token", token);
final AppUser appUser = JsonUtils.json2Obj(HttpClientUtils.doGet(USER_INFO_URL, null, headers), AppUser.class);//获取deviceToken final AppUser appUser = JsonUtils.json2Obj(HttpClientUtils.doGet(USER_INFO_URL, null, headers), AppUser.class);//获取deviceToken
userSocketInfo.setDeviceTokenParam(new DeviceTokenParam().setDeviceToken(appUser.getDeviceToken()).setDeviceType(appUser.getDeviceType()));
channelGroup.USER_GROUP.put(userId, userSocketInfo); channelGroup.USER_GROUP.put(userId, userSocketInfo);
channelGroup.USER_DEVICE_PUSH_TOKEN.put(userId, new DeviceTokenParam().setDeviceToken(appUser.getDeviceToken()).setDeviceType(appUser.getDeviceType()));
this.restoreBindingRelationship(userId); //恢复历史绑定关系 this.restoreBindingRelationship(userId); //恢复历史绑定关系
this.broadcastUserOnline(userId); //通知客服 用户上线 this.broadcastUserOnline(userId); //通知客服 用户上线
log.info("用户: " + userId + " 上线"); log.info("用户: " + userId + " 上线");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment