gemercheung 2 vuotta sitten
vanhempi
commit
de9ac1fafc
2 muutettua tiedostoa jossa 11 lisäystä ja 5 poistoa
  1. 3 0
      src/room/actions/action.d.ts
  2. 8 5
      src/room/actions/actions.service.ts

+ 3 - 0
src/room/actions/action.d.ts

@@ -30,6 +30,7 @@ interface DanmakuDataType {
 
 interface MutedStateType {
   muted: boolean;
+  roomId?: string;
   type: actionType['users-muted'];
   userId: string;
 }
@@ -38,9 +39,11 @@ interface TypingStateType {
   words: boolean;
   type: actionType['users-words'];
   userId: string;
+  roomId?: string;
 }
 
 interface KickStateType {
   type: actionType['users-kicked'];
   userId: string;
+  roomId?: string;
 }

+ 8 - 5
src/room/actions/actions.service.ts

@@ -29,10 +29,11 @@ export class ActionsService {
         'handleAllAction',
       );
     }
+
     this.roomService.logger.warn(
-      `当前--broadcast:${roomId},
-      data:${JSON.stringify(data)}
-       action:${data.type} ,isLeader:${isSocketLeader()}`,
+      `当前--broadcast:${roomId}, data:${JSON.stringify(data)}action:${
+        data.type
+      } ,isLeader:${isSocketLeader()}`,
       'handleAllAction',
     );
     switch (data.type) {
@@ -46,11 +47,13 @@ export class ActionsService {
         break;
       case 'users-muted':
         const mutedParams = data as any as MutedStateType;
+        mutedParams.roomId = roomId;
         isSocketLeader() && (await this.handleMutedState(mutedParams));
         await this.roomService.handleRoomStatusAction(socket);
         break;
       case 'users-words':
         const typingParams = data as any as TypingStateType;
+        typingParams.roomId = roomId;
         isSocketLeader() && (await this.handleTypingState(typingParams));
         this.roomService.handleRoomStatusAction(socket);
         await this.roomService.handleRoomStatusAction(socket);
@@ -86,7 +89,7 @@ export class ActionsService {
   }
   async handleMutedState(data: MutedStateType) {
     if (data) {
-      const roomId = this.roomService._userInfo.RoomId;
+      const roomId = data.roomId;
       const userId = data.userId;
       const mutedState = data.muted;
       this.roomService.logger.warn(
@@ -98,7 +101,7 @@ export class ActionsService {
   }
   async handleTypingState(data: TypingStateType) {
     if (data) {
-      const roomId = this.roomService._userInfo.RoomId;
+      const roomId = data.roomId;
       const userId = data.userId;
       const wordsState = data.words;
       await this.userService.updateUserTypingState(roomId, userId, wordsState);