master
parent
f05b0c2641
commit
025362469b
|
|
@ -239,6 +239,28 @@ public class EXGameController extends GameController {
|
||||||
String roomId = params.getString("roomid");
|
String roomId = params.getString("roomid");
|
||||||
int groupId = params.getInt("groupid");
|
int groupId = params.getInt("groupid");
|
||||||
|
|
||||||
|
//检查机器人是否已经在房间中
|
||||||
|
RobotUser existingUser = getRobotRoomInfo(String.valueOf(robotId));
|
||||||
|
if (existingUser != null && existingUser.getCurrentRoomId() > 0) {
|
||||||
|
String existingConnecId = existingUser.getCurrentRoomId() + "_" + robotId;
|
||||||
|
log.warn("机器人{}已在房间{}中,connecId: {}", robotId, existingUser.getCurrentRoomId(), existingConnecId);
|
||||||
|
|
||||||
|
//检查现有连接状态
|
||||||
|
TaurusClient existingClient = existingUser.getClient();
|
||||||
|
if (existingClient == null || !existingClient.isConnected()) {
|
||||||
|
log.warn("现有连接不健康,准备清理并重新加入");
|
||||||
|
robotConnectionManager.disconnectFromGameServer(existingConnecId);
|
||||||
|
} else {
|
||||||
|
log.info("现有连接健康,跳过重复加入");
|
||||||
|
//返回成功响应
|
||||||
|
ITObject response = TObject.newInstance();
|
||||||
|
response.putString("status", "success");
|
||||||
|
response.putString("message", "机器人已在房间中");
|
||||||
|
MainServer.instance.sendResponse(gid, 0, response, session);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//检查Redis中该房间是否真的包含当前机器人
|
//检查Redis中该房间是否真的包含当前机器人
|
||||||
if (!checkRobotInRoomRedis(roomId, String.valueOf(robotId))) {
|
if (!checkRobotInRoomRedis(roomId, String.valueOf(robotId))) {
|
||||||
//Redis中不存在该机器人 清理本地可能的错误映射
|
//Redis中不存在该机器人 清理本地可能的错误映射
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue