gemercheung 3 éve
szülő
commit
52bbcdddd8
2 módosított fájl, 6 hozzáadás és 5 törlés
  1. 3 2
      src/controller/room/assistant.js
  2. 3 3
      src/controller/room/index.js

+ 3 - 2
src/controller/room/assistant.js

@@ -406,12 +406,13 @@ export class RoomAssistant {
   async setOnlineStatus(roomId, userId, user) {
     user.onlineStatus = 1;
     await updateRoomUser(this.roomId, this.userId, user);
+    this.silentUpdateRoom(roomId);
   }
   // 静默认更新房间状态
   async silentUpdateRoom(roomId) {
     const AllRoomUsers = await getAllRoomUsers(roomId);
-    this.socket.broadcast.to(roomId).emit(EVENT.silentUpdateRoom,{
-      users:AllRoomUsers
+    this.socket.broadcast.to(roomId).emit(EVENT.silentUpdateRoom, {
+      users: AllRoomUsers,
     });
   }
   // 主动断开

+ 3 - 3
src/controller/room/index.js

@@ -131,12 +131,12 @@ export class RoomController extends BasicController {
       console.log("roomId", this.roomId);
       this.socket.join(this.roomId);
 
-      const isInRoom = await isUserInRoom(this.roomId, this.userId);
-      console.log("测试-强制上线", isInRoom, this.roomId, this.userId);
+      const isInRoom = await isUserInRoom(this.roomId, this.user.userId);
+      console.log("测试-强制上线", isInRoom, this.roomId, this.user.userId);
       if (isInRoom) {
         if (Number(isInRoom.onlineStatus) === 0) {
           console.log("在房间人员掉线人员,强制上线!", isInRoom);
-          this.roomAssistant.setOnlineStatus(this.roomId, this.userId, isInRoom);
+          this.roomAssistant.setOnlineStatus(this.roomId, this.user.userId, isInRoom);
         }
       }
     } else {