Ver código fonte

上限提示

gemercheung 3 anos atrás
pai
commit
9412c8764e
2 arquivos alterados com 8 adições e 5 exclusões
  1. 8 4
      src/controller/connectController.js
  2. 0 1
      src/service/userService.js

+ 8 - 4
src/controller/connectController.js

@@ -36,10 +36,14 @@ export class ConnectController extends BasicController {
         setTimeout(async () => {
         setTimeout(async () => {
           // 有可客户端主动断开时
           // 有可客户端主动断开时
           if (Number(user.onlineStatus) === 1) {
           if (Number(user.onlineStatus) === 1) {
-            console.log("已在线,被断开后", user);
-            user.onlineStatus = 0;
-            await updateRoomUser(roomId, userId, user);
-            await this.roomController.roomAssistant.notifyUsersChange(roomId, user, false);
+            const res = await this.checkRoomMaximum(roomId);
+  
+            if (!res.isMax) {
+              console.log("已在线,被断开后", user);
+              user.onlineStatus = 0;
+              await updateRoomUser(roomId, userId, user);
+              await this.roomController.roomAssistant.notifyUsersChange(roomId, user, false);
+            }
           }
           }
         }, 1000);
         }, 1000);
 
 

+ 0 - 1
src/service/userService.js

@@ -1,5 +1,4 @@
 import { pubClient } from "../connection/redis.js";
 import { pubClient } from "../connection/redis.js";
-
 const prefix = process.env.REDIS_PREFIX || "chat";
 const prefix = process.env.REDIS_PREFIX || "chat";
 
 
 const getInKey = (realKey) => {
 const getInKey = (realKey) => {