Displaying circle on join
So far, someone joining a map would not see the circles of groups already formed until someone moves in the group (because the "circle_moved_or_updated" event was not fired when someone arrives) This commit fixes this behaviour. Someone entering a room will receive an event for each and every group currently formed.
This commit is contained in:
parent
517d3981d1
commit
4cca1c1e58
@ -281,12 +281,23 @@ export class IoSocketController {
|
|||||||
this.Worlds.set(messageUserPosition.roomId, world);
|
this.Worlds.set(messageUserPosition.roomId, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
//join world
|
|
||||||
let world : World|undefined = this.Worlds.get(messageUserPosition.roomId);
|
let world : World|undefined = this.Worlds.get(messageUserPosition.roomId);
|
||||||
|
|
||||||
|
|
||||||
if(world) {
|
if(world) {
|
||||||
|
// Dispatch groups position to newly connected user
|
||||||
|
world.getGroups().forEach((group: Group) => {
|
||||||
|
Client.emit(SockerIoEvent.GROUP_CREATE_UPDATE, {
|
||||||
|
position: group.getPosition(),
|
||||||
|
groupId: group.getId()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
//join world
|
||||||
world.join(messageUserPosition);
|
world.join(messageUserPosition);
|
||||||
this.Worlds.set(messageUserPosition.roomId, world);
|
this.Worlds.set(messageUserPosition.roomId, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,6 +43,10 @@ export class World {
|
|||||||
this.groupDeletedCallback = groupDeletedCallback;
|
this.groupDeletedCallback = groupDeletedCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getGroups(): Group[] {
|
||||||
|
return this.groups;
|
||||||
|
}
|
||||||
|
|
||||||
public join(userPosition: MessageUserPosition): void {
|
public join(userPosition: MessageUserPosition): void {
|
||||||
this.users.set(userPosition.userId, {
|
this.users.set(userPosition.userId, {
|
||||||
id: userPosition.userId,
|
id: userPosition.userId,
|
||||||
|
Loading…
Reference in New Issue
Block a user