Fixed socket architecture a bit

master
Håvar Aambø Fosstveit 2018-10-22 12:56:19 +02:00
parent c56928b184
commit 64224fa830
2 changed files with 5 additions and 11 deletions

View File

@ -21,7 +21,7 @@ const torrentClient = new WebTorrent({
class Room extends EventEmitter
{
constructor(roomId, mediaServer)
constructor(roomId, mediaServer, io)
{
logger.info('constructor() [roomId:"%s"]', roomId);
@ -38,6 +38,8 @@ class Room extends EventEmitter
this._fileHistory = [];
this._io = io;
this._signalingPeers = new Map();
try
@ -177,10 +179,7 @@ class Room extends EventEmitter
}
}
// Spread to room
this.emit(
'active-speaker',
{
this._io.to(this._roomId).emit('active-speaker', {
peerName : activePeer ? activePeer.name : null
});
});

View File

@ -145,7 +145,7 @@ io.on('connection', (socket) =>
try
{
room = new Room(roomId, mediaServer);
room = new Room(roomId, mediaServer, io);
global.APP_ROOM = room;
}
@ -165,11 +165,6 @@ io.on('connection', (socket) =>
rooms.set(roomId, room);
room.on('active-speaker', (message) =>
{
io.to(roomId).emit('active-speaker', message);
});
room.on('close', () =>
{
rooms.delete(roomId);