gemercheung пре 2 година
родитељ
комит
3fbd745d9a
1 измењених фајлова са 7 додато и 8 уклоњено
  1. 7 8
      src/room/room.service.ts

+ 7 - 8
src/room/room.service.ts

@@ -228,6 +228,10 @@ export class RoomService {
     const delUser = await this.userService.getUsersBy(RoomId, userId);
     const roomUsers = await this.userService.getRoomUsers(RoomId);
     const filterRoomUser = roomUsers.filter((i) => i.UserId !== userId);
+    this.logger.warn(
+      `RoomId: ${RoomId},userId:${userId} info:${JSON.stringify(delUser)}`,
+      'kick-user',
+    );
     if (delUser) {
       this.socketGateway.server.sockets.sockets.forEach((soc) => {
         const kickAction = () => {
@@ -242,24 +246,19 @@ export class RoomService {
         if (soc.data.user) {
           const userId = soc.data.user.UserId;
           if (userId === delUser.UserId) {
-            this.logger.warn(
-              `RoomId: ${RoomId},userId:${userId} socketId:${delUser.id}`,
-              'kick-user-userId',
-            );
+            this.logger.warn(`kick by UserId`, 'kick-user');
             kickAction();
           }
         } else {
           const userId = soc.id;
           if (userId === delUser.UserId) {
-            this.logger.warn(
-              `RoomId: ${RoomId},userId:${userId} socketId:${delUser.id}`,
-              'kick-user-socketId',
-            );
+            this.logger.warn(`kick by SocketID`, 'kick-user');
             kickAction();
           }
         }
       });
     }
+
     const res = await this.userService.deleteRoomUser(RoomId, userId);
     if (res) {
       this.socketGateway.server.to(RoomId).emit('action', {