Fix shares information to enter into Webrtc room.

- Refactor share position in world class.
- Update selects a client to send information about connecting WebRtc room.
This commit is contained in:
gparant 2020-05-08 11:54:47 +02:00
parent 16cf33755c
commit 41f5b5a1f6
2 changed files with 11 additions and 8 deletions

View file

@ -91,9 +91,6 @@ export class IoSocketController {
return socket.emit(SockerIoEvent.MESSAGE_ERROR, JSON.stringify({message: messageUserPosition.message}));
}
// update position in the worl
this.World.updatePosition(messageUserPosition);
// sending to all clients in room except sender
this.saveUserInformation((socket as ExSocketInterface), messageUserPosition);
@ -192,8 +189,8 @@ export class IoSocketController {
if (this.Io.sockets.adapter.rooms[roomId].length < 2 || this.Io.sockets.adapter.rooms[roomId].length >= 4) {
return;
}
let clients: Array<any> = Object.values(this.Io.sockets.sockets);
let clients: Array<ExSocketInterface> = Object.values(this.Io.sockets.sockets)
.filter((client: ExSocketInterface) => client.webRtcRoomId && client.webRtcRoomId === roomId);
//send start at one client to initialise offer webrtc
//send all users in room to create PeerConnection in front
clients.forEach((client: ExSocketInterface, index: number) => {
@ -228,7 +225,7 @@ export class IoSocketController {
if (!rooms.refreshUserPosition) {
rooms.refreshUserPosition = RefreshUserPositionFunction;
}
rooms.refreshUserPosition(rooms, this.Io);
rooms.refreshUserPosition(rooms, this.Io, this.World);
}
//Hydrate and manage error