Properly delete rooms in Pusher in case of connection error and empty room
Closes #1646
This commit is contained in:
parent
404404d2bf
commit
e0aab9c0ce
2 changed files with 17 additions and 6 deletions
|
@ -351,11 +351,7 @@ export class SocketManager implements ZoneEventListener {
|
|||
debug("Leaving room %s.", socket.roomId);
|
||||
|
||||
room.leave(socket);
|
||||
if (room.isEmpty()) {
|
||||
room.close();
|
||||
this.rooms.delete(socket.roomId);
|
||||
debug("Room %s is empty. Deleting.", socket.roomId);
|
||||
}
|
||||
this.deleteRoomIfEmpty(room);
|
||||
} else {
|
||||
console.error("Could not find the GameRoom the user is leaving!");
|
||||
}
|
||||
|
@ -374,6 +370,14 @@ export class SocketManager implements ZoneEventListener {
|
|||
}
|
||||
}
|
||||
|
||||
public deleteRoomIfEmpty(room: PusherRoom): void {
|
||||
if (room.isEmpty()) {
|
||||
room.close();
|
||||
this.rooms.delete(room.roomUrl);
|
||||
debug("Room %s is empty. Deleting.", room.roomUrl);
|
||||
}
|
||||
}
|
||||
|
||||
async getOrCreateRoom(roomUrl: string): Promise<PusherRoom> {
|
||||
//check and create new world for a room
|
||||
let room = this.rooms.get(roomUrl);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue