Deleting world when empty.
This commit is contained in:
parent
d9e6b501b1
commit
9bdcc9da98
@ -297,6 +297,9 @@ export class IoSocketController {
|
||||
const world : World|undefined = this.Worlds.get(Client.roomId);
|
||||
if(world){
|
||||
world.leave(Client);
|
||||
if (world.isEmpty()) {
|
||||
this.Worlds.delete(Client.roomId);
|
||||
}
|
||||
}
|
||||
//user leave previous room
|
||||
Client.leave(Client.roomId);
|
||||
|
@ -72,6 +72,10 @@ export class World {
|
||||
this.users.delete(user.userId);
|
||||
}
|
||||
|
||||
public isEmpty(): boolean {
|
||||
return this.users.size === 0;
|
||||
}
|
||||
|
||||
public updatePosition(socket : Identificable, userPosition: PointInterface): void {
|
||||
const user = this.users.get(socket.userId);
|
||||
if(typeof user === 'undefined') {
|
||||
|
Loading…
Reference in New Issue
Block a user