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:
parent
16cf33755c
commit
41f5b5a1f6
@ -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
|
||||
|
@ -1,6 +1,8 @@
|
||||
import {ExtRoomsInterface} from "./ExtRoomsInterface";
|
||||
import socketIO = require('socket.io');
|
||||
import {ExSocketInterface} from "_Model/Websocket/ExSocketInterface";
|
||||
import {ExSocketInterface} from "./ExSocketInterface";
|
||||
import {MessageUserPosition} from "./MessageUserPosition";
|
||||
import {World} from "_Model/World";
|
||||
|
||||
export class ExtRooms implements ExtRoomsInterface{
|
||||
userPositionMapByRoom: any;
|
||||
@ -9,7 +11,7 @@ export class ExtRooms implements ExtRoomsInterface{
|
||||
[room: string]: SocketIO.Room;
|
||||
}
|
||||
|
||||
let RefreshUserPositionFunction = function(rooms : ExtRooms, Io: socketIO.Server) {
|
||||
let RefreshUserPositionFunction = function(rooms : ExtRooms, Io: socketIO.Server, World : World) {
|
||||
let clients = Io.clients();
|
||||
let socketsKey = Object.keys(Io.clients().sockets);
|
||||
|
||||
@ -35,6 +37,10 @@ let RefreshUserPositionFunction = function(rooms : ExtRooms, Io: socketIO.Server
|
||||
dataArray = [data];
|
||||
}
|
||||
mapPositionUserByRoom.set(data.roomId, dataArray);
|
||||
|
||||
// update position in the worl
|
||||
let messageUserPosition = new MessageUserPosition(data);
|
||||
World.updatePosition(messageUserPosition);
|
||||
}
|
||||
rooms.userPositionMapByRoom = Array.from(mapPositionUserByRoom);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user