Correctly cleaning room in pusher even if an exception occurs

Closes #1646 (again)
This commit is contained in:
David Négrier 2021-12-20 15:33:47 +01:00
parent e0aab9c0ce
commit d792d35d09
2 changed files with 13 additions and 5 deletions

View file

@ -370,7 +370,7 @@ export class SocketManager implements ZoneEventListener {
}
}
public deleteRoomIfEmpty(room: PusherRoom): void {
private deleteRoomIfEmpty(room: PusherRoom): void {
if (room.isEmpty()) {
room.close();
this.rooms.delete(room.roomUrl);
@ -378,6 +378,13 @@ export class SocketManager implements ZoneEventListener {
}
}
public deleteRoomIfEmptyFromId(roomUrl: string): void {
const room = this.rooms.get(roomUrl);
if (room) {
this.deleteRoomIfEmpty(room);
}
}
async getOrCreateRoom(roomUrl: string): Promise<PusherRoom> {
//check and create new world for a room
let room = this.rooms.get(roomUrl);