Merge pull request #113 from thecodingmachine/display_circle_on_startup

Displaying circle on join
This commit is contained in:
David Négrier 2020-05-14 22:02:41 +02:00 committed by GitHub
commit 76b43245c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -281,12 +281,23 @@ export class IoSocketController {
this.Worlds.set(messageUserPosition.roomId, world);
}
//join world
let world : World|undefined = this.Worlds.get(messageUserPosition.roomId);
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);
this.Worlds.set(messageUserPosition.roomId, world);
}
}
/**

View File

@ -43,6 +43,10 @@ export class World {
this.groupDeletedCallback = groupDeletedCallback;
}
public getGroups(): Group[] {
return this.groups;
}
public join(userPosition: MessageUserPosition): void {
this.users.set(userPosition.userId, {
id: userPosition.userId,