|
@@ -72,7 +72,8 @@ export class RoomService {
|
|
const { RoomId, UserId } = socket.data.user;
|
|
const { RoomId, UserId } = socket.data.user;
|
|
if (RoomId && UserId) {
|
|
if (RoomId && UserId) {
|
|
//标记主动退出房间
|
|
//标记主动退出房间
|
|
- if (socket.data.isRequestExit !== 1) {
|
|
|
|
|
|
+
|
|
|
|
+ if (socket.data.isRequestExit !== 1 && socket.data.isKick !== 1) {
|
|
const roomUsers = await this.userService.getRoomUsers(RoomId);
|
|
const roomUsers = await this.userService.getRoomUsers(RoomId);
|
|
this.socketGateway.server.to(RoomId).emit('action', {
|
|
this.socketGateway.server.to(RoomId).emit('action', {
|
|
type: 'user-leave',
|
|
type: 'user-leave',
|
|
@@ -209,7 +210,7 @@ export class RoomService {
|
|
* 房间T人
|
|
* 房间T人
|
|
* @param message
|
|
* @param message
|
|
*/
|
|
*/
|
|
- async handleKickAction(socket: Socket, 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(
|
|
this.logger.warn(
|
|
`RoomId: ${RoomId},userId:${userId} socketId:${delUser.id}`,
|
|
`RoomId: ${RoomId},userId:${userId} socketId:${delUser.id}`,
|
|
@@ -218,9 +219,13 @@ export class RoomService {
|
|
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) {
|
|
- socket.data.isKick = true;
|
|
|
|
this.socketGateway.server.sockets.sockets.forEach((soc) => {
|
|
this.socketGateway.server.sockets.sockets.forEach((soc) => {
|
|
if (soc.id === delUser.id) {
|
|
if (soc.id === delUser.id) {
|
|
|
|
+ soc.data.isKick = 1;
|
|
|
|
+ soc.emit('action', {
|
|
|
|
+ type: 'user-be-kicked',
|
|
|
|
+ user: delUser,
|
|
|
|
+ });
|
|
soc.disconnect(true);
|
|
soc.disconnect(true);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -292,5 +297,4 @@ export class RoomService {
|
|
.emit('action', { type: 'leader-dismiss' });
|
|
.emit('action', { type: 'leader-dismiss' });
|
|
return Promise.resolve(true);
|
|
return Promise.resolve(true);
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|