|
@@ -80,8 +80,83 @@ export class RoomManagerController {
|
|
|
count: roomUsers.length,
|
|
|
};
|
|
|
}
|
|
|
+ }
|
|
|
+ @Get('/valid/:id')
|
|
|
+ @ApiOperation({ summary: '获取当前房间是否存在' })
|
|
|
+ @ApiParam({
|
|
|
+ name: 'id',
|
|
|
+ required: true,
|
|
|
+ description: '房间ID',
|
|
|
+ schema: { oneOf: [{ type: 'string' }] },
|
|
|
+ type: 'string',
|
|
|
+ })
|
|
|
+ @ApiResponse({
|
|
|
+ description: 'The record has been successfully created.',
|
|
|
+ type: Boolean,
|
|
|
+ })
|
|
|
+ async getRoomValid(@Param('id') id: string) {
|
|
|
+ this.roomService.logger.log(`roomId: ${id}`, 'api-getRoomValid');
|
|
|
+ if (id) {
|
|
|
+ const isValidRoom = await this.usersService.isValidRoom(id);
|
|
|
+ console.log('isValidRoom', isValidRoom);
|
|
|
+ return isValidRoom;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- // const res = await this.roomService.handleRoomDismiss(id);
|
|
|
- // return res;
|
|
|
+ @Get('/kick/:id/:userId')
|
|
|
+ @ApiOperation({ summary: '将用户踢出房间' })
|
|
|
+ @ApiParam({
|
|
|
+ name: 'id',
|
|
|
+ required: true,
|
|
|
+ description: '房间ID',
|
|
|
+ schema: { oneOf: [{ type: 'string' }] },
|
|
|
+ type: 'string',
|
|
|
+ })
|
|
|
+ @ApiParam({
|
|
|
+ name: 'userId',
|
|
|
+ required: true,
|
|
|
+ description: '用户ID',
|
|
|
+ schema: { oneOf: [{ type: 'string' }] },
|
|
|
+ type: 'string',
|
|
|
+ })
|
|
|
+ @ApiResponse({
|
|
|
+ description: 'The record has been successfully created.',
|
|
|
+ type: Boolean,
|
|
|
+ })
|
|
|
+ async getRoomUserKicked(
|
|
|
+ @Param('id') id: string,
|
|
|
+ @Param('userId') userId: string,
|
|
|
+ ) {
|
|
|
+ this.roomService.logger.log(
|
|
|
+ `roomId: ${id}userId:${userId}`,
|
|
|
+ 'api-getRoomUserKicked',
|
|
|
+ );
|
|
|
+ if (id && userId) {
|
|
|
+ const roomId = id;
|
|
|
+ this.roomService.handleKickAction(roomId, userId);
|
|
|
+ // const delUser = await this.usersService.getUsersBy(roomId, userId);
|
|
|
+ // this.roomService.logger.warn(
|
|
|
+ // `RoomId: ${roomId},userId:${userId} socketId:${delUser.id}`,
|
|
|
+ // 'kick-user',
|
|
|
+ // );
|
|
|
+ // const roomUsers = await this.usersService.getRoomUsers(roomId);
|
|
|
+ // const filterRoomUser = roomUsers.filter((i) => i.UserId !== userId);
|
|
|
+ // if (delUser) {
|
|
|
+ // this.roomService.socketGateway.server.sockets.sockets.forEach((soc) => {
|
|
|
+ // if (soc.id === delUser.id) {
|
|
|
+ // soc.data.isKick = true;
|
|
|
+ // soc.disconnect(true);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // const res = await this.usersService.deleteRoomUser(roomId, userId);
|
|
|
+ // if (res) {
|
|
|
+ // this.roomService.socketGateway.server.to(roomId).emit('action', {
|
|
|
+ // type: 'user-exit',
|
|
|
+ // user: delUser,
|
|
|
+ // members: filterRoomUser,
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ }
|
|
|
}
|
|
|
}
|