gemercheung 2 years ago
parent
commit
e29aa1dbbe
1 changed files with 6 additions and 0 deletions
  1. 6 0
      src/socket/socket.gateway.ts

+ 6 - 0
src/socket/socket.gateway.ts

@@ -156,4 +156,10 @@ export class SocketGateway
   ): Promise<void> {
   ): Promise<void> {
     await this.roomService.handleExitAction(socket, message);
     await this.roomService.handleExitAction(socket, message);
   }
   }
+
+  @SubscribeMessage('active-status')
+  async handleActive(@ConnectedSocket() socket: Socket) {
+    const sockets = this.server.sockets.sockets.size;
+    socket.emit('active-status', { number: sockets });
+  }
 }
 }