Fixed socket architecture a bit

This commit is contained in:
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
+4 -5
View File
@@ -21,7 +21,7 @@ const torrentClient = new WebTorrent({
class Room extends EventEmitter class Room extends EventEmitter
{ {
constructor(roomId, mediaServer) constructor(roomId, mediaServer, io)
{ {
logger.info('constructor() [roomId:"%s"]', roomId); logger.info('constructor() [roomId:"%s"]', roomId);
@@ -38,6 +38,8 @@ class Room extends EventEmitter
this._fileHistory = []; this._fileHistory = [];
this._io = io;
this._signalingPeers = new Map(); this._signalingPeers = new Map();
try try
@@ -177,10 +179,7 @@ class Room extends EventEmitter
} }
} }
// Spread to room this._io.to(this._roomId).emit('active-speaker', {
this.emit(
'active-speaker',
{
peerName : activePeer ? activePeer.name : null peerName : activePeer ? activePeer.name : null
}); });
}); });
+1 -6
View File
@@ -145,7 +145,7 @@ io.on('connection', (socket) =>
try try
{ {
room = new Room(roomId, mediaServer); room = new Room(roomId, mediaServer, io);
global.APP_ROOM = room; global.APP_ROOM = room;
} }
@@ -165,11 +165,6 @@ io.on('connection', (socket) =>
rooms.set(roomId, room); rooms.set(roomId, room);
room.on('active-speaker', (message) =>
{
io.to(roomId).emit('active-speaker', message);
});
room.on('close', () => room.on('close', () =>
{ {
rooms.delete(roomId); rooms.delete(roomId);