|
@@ -10,10 +10,7 @@ import com.zanxiang.game.module.manage.enums.KfRoomMsgTypeEnum;
|
|
|
import com.zanxiang.game.module.manage.enums.KfWebSocketMsgEnum;
|
|
|
import com.zanxiang.game.module.manage.pojo.dto.KfWebSocketMsgDTO;
|
|
|
import com.zanxiang.game.module.manage.pojo.params.KfWebSocketMsgParam;
|
|
|
-import com.zanxiang.game.module.manage.service.IKfQuickReplyService;
|
|
|
-import com.zanxiang.game.module.manage.service.IKfRoomMsgService;
|
|
|
-import com.zanxiang.game.module.manage.service.IKfRoomService;
|
|
|
-import com.zanxiang.game.module.manage.service.IKfSessionUserService;
|
|
|
+import com.zanxiang.game.module.manage.service.*;
|
|
|
import com.zanxiang.game.module.manage.service.api.KfWxApiService;
|
|
|
import com.zanxiang.game.module.manage.utils.FileUtil;
|
|
|
import com.zanxiang.game.module.mybatis.entity.KfRoom;
|
|
@@ -66,6 +63,9 @@ public class KfMsgWebsocketHandler implements WebSocketHandler {
|
|
|
@Autowired
|
|
|
private KfWxApiService wxApiService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IGameAuthRoleService gameAuthRoleService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private IKfQuickReplyService kfQuickReplyService;
|
|
|
|
|
@@ -327,6 +327,8 @@ public class KfMsgWebsocketHandler implements WebSocketHandler {
|
|
|
.gameId(gameId)
|
|
|
.roomList(onlineRoomList)
|
|
|
.build());
|
|
|
+ //释放锁
|
|
|
+ distributedLockComponent.unlock(RedisKeyConstant.KF_MSG_USER_CONNECT_JOIN + kfRoom.getOpenId());
|
|
|
}
|
|
|
|
|
|
private void finishRoomList(WebSocketSession session, KfWebSocketMsgParam param) {
|
|
@@ -368,15 +370,16 @@ public class KfMsgWebsocketHandler implements WebSocketHandler {
|
|
|
}
|
|
|
|
|
|
private void userConnectJoin(WebSocketSession session, KfWebSocketMsgParam param) {
|
|
|
+ //参数判断
|
|
|
if (Strings.isBlank(param.getOpenId())) {
|
|
|
this.sendMessage(session, KfWebSocketMsgDTO.fail(param.getWebSocketMsgType(),
|
|
|
"接入玩家参数错误, openId不可为空, param : " + JsonUtil.toString(param)));
|
|
|
return;
|
|
|
}
|
|
|
- //触发玩家接入线程锁
|
|
|
- if (!distributedLockComponent.doLock(RedisKeyConstant.KF_MSG_USER_CONNECT_JOIN + param.getOpenId(),
|
|
|
- 0L, 5L, TimeUnit.MINUTES)) {
|
|
|
- this.sendMessage(session, KfWebSocketMsgDTO.fail(param.getWebSocketMsgType(), "玩家已被其他客服接入"));
|
|
|
+ //判断是否为客服
|
|
|
+ if (!gameAuthRoleService.isCustomer()) {
|
|
|
+ this.sendMessage(session, KfWebSocketMsgDTO.fail(param.getWebSocketMsgType(),
|
|
|
+ "非客服人员, 不可接待玩家, param : " + JsonUtil.toString(param)));
|
|
|
return;
|
|
|
}
|
|
|
//玩家信息, 判断玩家是否已经被接入
|
|
@@ -385,6 +388,12 @@ public class KfMsgWebsocketHandler implements WebSocketHandler {
|
|
|
this.sendMessage(session, KfWebSocketMsgDTO.fail(param.getWebSocketMsgType(), "玩家已被其他客服接入"));
|
|
|
return;
|
|
|
}
|
|
|
+ //触发玩家接入线程锁
|
|
|
+ if (!distributedLockComponent.doLock(RedisKeyConstant.KF_MSG_USER_CONNECT_JOIN + param.getOpenId(),
|
|
|
+ 0L, 5L, TimeUnit.MINUTES)) {
|
|
|
+ this.sendMessage(session, KfWebSocketMsgDTO.fail(param.getWebSocketMsgType(), "玩家已被其他客服接入"));
|
|
|
+ return;
|
|
|
+ }
|
|
|
//玩家更新为已接入
|
|
|
kfSessionUserService.update(new LambdaUpdateWrapper<KfSessionUser>()
|
|
|
.set(KfSessionUser::getIsWait, Boolean.FALSE)
|
|
@@ -417,8 +426,6 @@ public class KfMsgWebsocketHandler implements WebSocketHandler {
|
|
|
.gameId(param.getGameId())
|
|
|
.waitUserList(waitUserList)
|
|
|
.build());
|
|
|
- //释放锁
|
|
|
- distributedLockComponent.unlock(RedisKeyConstant.KF_MSG_USER_CONNECT_JOIN + param.getOpenId());
|
|
|
}
|
|
|
|
|
|
private void kfCreateConnect(WebSocketSession session, KfWebSocketMsgEnum msgTypeEnum, Long gameId) {
|