WIP: how to respond to too many users

This commit is contained in:
arp 2020-10-21 17:43:00 +02:00
parent 664e699fd3
commit 326c2e4183
5 changed files with 61 additions and 12 deletions

View file

@ -10,6 +10,7 @@ import {ViewportInterface} from "_Model/Websocket/ViewportMessage";
import {Movable} from "_Model/Movable";
import {extractDataFromPrivateRoomId, extractRoomSlugPublicRoomId, isRoomAnonymous} from "./RoomIdentifier";
import {arrayIntersect} from "../Services/ArrayHelper";
import {MAX_USERS_PER_ROOM} from "_Enum/EnvironmentVariable";
export type ConnectCallback = (user: User, group: Group) => void;
export type DisconnectCallback = (user: User, group: Group) => void;
@ -179,6 +180,10 @@ export class GameRoom {
}
}
isFull() : boolean {
return this.getUsers().size > MAX_USERS_PER_ROOM;
}
/**
* Makes a user leave a group and closes and destroy the group if the group contains only one remaining person.
*