|
@@ -226,21 +226,37 @@ export class RoomService {
|
|
*/
|
|
*/
|
|
async handleKickAction(RoomId: string, userId: string) {
|
|
async handleKickAction(RoomId: string, userId: string) {
|
|
const delUser = await this.userService.getUsersBy(RoomId, userId);
|
|
const delUser = await this.userService.getUsersBy(RoomId, userId);
|
|
- this.logger.warn(
|
|
|
|
- `RoomId: ${RoomId},userId:${userId} socketId:${delUser.id}`,
|
|
|
|
- 'kick-user',
|
|
|
|
- );
|
|
|
|
const roomUsers = await this.userService.getRoomUsers(RoomId);
|
|
const roomUsers = await this.userService.getRoomUsers(RoomId);
|
|
const filterRoomUser = roomUsers.filter((i) => i.UserId !== userId);
|
|
const filterRoomUser = roomUsers.filter((i) => i.UserId !== userId);
|
|
if (delUser) {
|
|
if (delUser) {
|
|
this.socketGateway.server.sockets.sockets.forEach((soc) => {
|
|
this.socketGateway.server.sockets.sockets.forEach((soc) => {
|
|
- if (soc.id === delUser.id) {
|
|
|
|
|
|
+ const kickAction = () => {
|
|
soc.data.isKick = 1;
|
|
soc.data.isKick = 1;
|
|
soc.emit('action', {
|
|
soc.emit('action', {
|
|
type: 'user-be-kicked',
|
|
type: 'user-be-kicked',
|
|
user: delUser,
|
|
user: delUser,
|
|
});
|
|
});
|
|
soc.disconnect(true);
|
|
soc.disconnect(true);
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ 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',
|
|
|
|
+ );
|
|
|
|
+ kickAction();
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ const userId = soc.id;
|
|
|
|
+ if (userId === delUser.UserId) {
|
|
|
|
+ this.logger.warn(
|
|
|
|
+ `RoomId: ${RoomId},userId:${userId} socketId:${delUser.id}`,
|
|
|
|
+ 'kick-user-socketId',
|
|
|
|
+ );
|
|
|
|
+ kickAction();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|