gemercheung 3 years ago
parent
commit
2e6f8e078f
2 changed files with 6 additions and 1 deletions
  1. 2 1
      src/controller/connectController.js
  2. 4 0
      src/controller/room/assistant.js

+ 2 - 1
src/controller/connectController.js

@@ -68,7 +68,8 @@ export class ConnectController extends BasicController {
           if (Number(user.onlineStatus) === 1) {
             // const res = await this.roomController.roomAssistant.checkRoomMaximum(roomId);
             const isInRoom = await isUserInRoom(roomId, user.userId);
-            if (!this.roomController.roomAssistant.roomMax && isInRoom) {
+            const illegalMaster = this.roomController.roomAssistant.illegalMaster
+            if (!this.roomController.roomAssistant.roomMax && isInRoom && this.roomController && !illegalMaster) {
               console.log("已在线,被断开后", isInRoom);
               isInRoom.onlineStatus = 0;
               this.roomController.user = isInRoom;

+ 4 - 0
src/controller/room/assistant.js

@@ -326,6 +326,7 @@ export class RoomAssistant {
         } else {
           const hasRoom = await this.redis.hVals(getInKey(roomId));
           if (hasRoom.length === 0) {
+            this.illegalMaster = false;
             this.room.logger.info("房主主动创建房间 :", { roomId, userId });
             await this.buildRoom(roomId, userId, user);
           } else {
@@ -333,12 +334,15 @@ export class RoomAssistant {
             const checkIsRoomMaster = await isRoomMaster(roomId, userId);
             console.log("isRoomMaster", checkIsRoomMaster);
             if (checkIsRoomMaster) {
+              this.illegalMaster = false;
               this.room.logger.info("房主已存在房间 :", { roomId, userId, from: user.from });
               await this.joinRoom(roomId, userId, user);
+              
               // this.notifyUserJitter(roomId);
             } else {
               this.room.logger.error("存在非法房主", roomId, userId);
               await removeRoomUser(roomId, userId);
+              this.illegalMaster = true;
               this.socket.broadcast.to(this.room.syncId).emit(EVENT.unKnowError);
             }
           }