HotFix ban user (#1318)
* HotFix ban user - Fix to permit to ban user with more sub tab openned - Fix to permit to send message ban to the user with more sub tab oppened * Fix CI * Run pretty
This commit is contained in:
parent
95af568653
commit
3d657b4a18
@ -72,6 +72,15 @@ export class GameRoom {
|
|||||||
public getUserById(id: number): User | undefined {
|
public getUserById(id: number): User | undefined {
|
||||||
return this.users.get(id);
|
return this.users.get(id);
|
||||||
}
|
}
|
||||||
|
public getUsersByUuid(uuid: string): User[] {
|
||||||
|
const userList: User[] = [];
|
||||||
|
for (const user of this.users.values()) {
|
||||||
|
if (user.uuid === uuid) {
|
||||||
|
userList.push(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return userList;
|
||||||
|
}
|
||||||
|
|
||||||
public join(socket: UserSocket, joinRoomMessage: JoinRoomMessage): User {
|
public join(socket: UserSocket, joinRoomMessage: JoinRoomMessage): User {
|
||||||
const positionMessage = joinRoomMessage.getPositionmessage();
|
const positionMessage = joinRoomMessage.getPositionmessage();
|
||||||
|
@ -675,8 +675,8 @@ export class SocketManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const recipient = room.getUserByUuid(recipientUuid);
|
const recipients = room.getUsersByUuid(recipientUuid);
|
||||||
if (recipient === undefined) {
|
if (recipients.length === 0) {
|
||||||
console.error(
|
console.error(
|
||||||
"In sendAdminMessage, could not find user with id '" +
|
"In sendAdminMessage, could not find user with id '" +
|
||||||
recipientUuid +
|
recipientUuid +
|
||||||
@ -685,6 +685,7 @@ export class SocketManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const recipient of recipients) {
|
||||||
const sendUserMessage = new SendUserMessage();
|
const sendUserMessage = new SendUserMessage();
|
||||||
sendUserMessage.setMessage(message);
|
sendUserMessage.setMessage(message);
|
||||||
sendUserMessage.setType("ban"); //todo: is the type correct?
|
sendUserMessage.setType("ban"); //todo: is the type correct?
|
||||||
@ -694,6 +695,7 @@ export class SocketManager {
|
|||||||
|
|
||||||
recipient.socket.write(serverToClientMessage);
|
recipient.socket.write(serverToClientMessage);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public banUser(roomId: string, recipientUuid: string, message: string): void {
|
public banUser(roomId: string, recipientUuid: string, message: string): void {
|
||||||
const room = this.rooms.get(roomId);
|
const room = this.rooms.get(roomId);
|
||||||
@ -706,8 +708,8 @@ export class SocketManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const recipient = room.getUserByUuid(recipientUuid);
|
const recipients = room.getUsersByUuid(recipientUuid);
|
||||||
if (recipient === undefined) {
|
if (recipients.length === 0) {
|
||||||
console.error(
|
console.error(
|
||||||
"In banUser, could not find user with id '" +
|
"In banUser, could not find user with id '" +
|
||||||
recipientUuid +
|
recipientUuid +
|
||||||
@ -716,6 +718,7 @@ export class SocketManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const recipient of recipients) {
|
||||||
// Let's leave the room now.
|
// Let's leave the room now.
|
||||||
room.leave(recipient);
|
room.leave(recipient);
|
||||||
|
|
||||||
@ -730,6 +733,7 @@ export class SocketManager {
|
|||||||
recipient.socket.write(serverToClientMessage);
|
recipient.socket.write(serverToClientMessage);
|
||||||
recipient.socket.end();
|
recipient.socket.end();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sendAdminRoomMessage(roomId: string, message: string) {
|
sendAdminRoomMessage(roomId: string, message: string) {
|
||||||
const room = this.rooms.get(roomId);
|
const room = this.rooms.get(roomId);
|
||||||
|
Loading…
Reference in New Issue
Block a user