|
@@ -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', {
|