Fixed socket architecture a bit
parent
c56928b184
commit
64224fa830
|
|
@ -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
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue