server/lib/Room.js
/**
	 * Factory function that creates and returns Room instance.
	 *
	 * @async
	 *
	 * @param {mediasoup.Worker} mediasoupWorkers - The mediasoup Worker in which a new
	 *   mediasoup Router must be created.
	 * @param {String} roomId - Id of the Room instance.
	 */
Factory function that creates and returns Room instance.
@async

@param {mediasoup.Worker} mediasoupWorkers - The mediasoup Worker in which a new
mediasoup Router must be created.
@param {String} roomId - Id of the Room instance.
Factory function that creates and returns Room instance . @async @param { mediasoup . Worker } mediasoupWorkers - The mediasoup Worker in which a new mediasoup Router must be created . @param { String } roomId - Id of the Room instance .
static async create({ mediasoupWorkers, roomId, peers })
	{
		logger.info('create() [roomId:"%s"]', roomId);
		const mediaCodecs = config.mediasoup.router.mediaCodecs;
		const mediasoupRouters = new Map();
		for (const worker of mediasoupWorkers)
		{
			const router = await worker.createRouter({ mediaCodecs });
			mediasoupRouters.set(router.id, router);
		}
		const firstRouter = mediasoupRouters.get(Room.getLeastLoadedRouter(
			mediasoupWorkers, peers, mediasoupRouters));
		const audioLevelObserver = await firstRouter.createAudioLevelObserver(
			{
				maxEntries : 1,
				threshold  : -80,
				interval   : 800
			});
		return new Room({
			roomId,
			mediasoupRouters,
			audioLevelObserver,
			mediasoupWorkers,
			peers
		});
	}
static async create ( { mediasoupWorkers , roomId , peers } ) { logger . info ( 'create() [roomId:"%s"]' , roomId ) ; const mediaCodecs = config . mediasoup . router . mediaCodecs ; const mediasoupRouters = new Map ( ) ; for ( const worker of mediasoupWorkers ) { const router = await worker . createRouter ( { mediaCodecs } ) ; mediasoupRouters . set ( router . id , router ) ; } const firstRouter = mediasoupRouters . get ( Room . getLeastLoadedRouter ( mediasoupWorkers , peers , mediasoupRouters ) ) ; const audioLevelObserver = await firstRouter . createAudioLevelObserver ( { maxEntries : 1 , threshold : - 80 , interval : 800 } ) ; return new Room ( { roomId , mediasoupRouters , audioLevelObserver , mediasoupWorkers , peers } ) ; }
Factory function that creates and returns Room instance.
Factory function that creates and returns Room instance .
// Router media codecs. // Create a mediasoup AudioLevelObserver on first router