From be0fe76135a4ab7b651a858ecf5c3095988b418b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2019 22:05:37 +0100 Subject: [PATCH] Bump eslint from 3.19.0 to 4.19.1 (#1504) --- erizo_controller/ROV/rovClient.js | 2 - erizo_controller/ROV/rovMetricsServer.js | 6 +- erizo_controller/common/amqper.js | 34 +- erizo_controller/common/logger.js | 6 +- .../common/semanticSdp/CandidateInfo.js | 3 +- .../common/semanticSdp/CodecInfo.js | 1 - .../common/semanticSdp/ICEInfo.js | 1 - .../common/semanticSdp/SDPInfo.js | 4 +- erizo_controller/erizoAgent/erizoAgent.js | 4 +- .../erizoController/ecCloudHandler.js | 2 +- .../erizoController/erizoController.js | 8 +- .../erizoController/models/Channel.js | 3 +- .../erizoController/models/Client.js | 17 +- .../erizoController/models/Room.js | 10 +- .../erizoController/roomController.js | 120 +++---- .../adapt_schemes/notify-break-recover.js | 4 +- erizo_controller/erizoJS/erizoJSController.js | 38 +-- erizo_controller/erizoJS/models/Client.js | 1 - erizo_controller/erizoJS/models/Connection.js | 15 +- erizo_controller/erizoJS/models/Node.js | 10 +- erizo_controller/erizoJS/models/Publisher.js | 15 +- .../erizoJS/models/SessionDescription.js | 7 +- .../test/erizoAgent/erizoAgent.js | 2 +- .../test/erizoController/erizoController.js | 316 +++++++++--------- .../test/erizoController/roomController.js | 22 +- .../test/erizoJS/erizoJSController.js | 70 ++-- erizo_controller/test/utils.js | 6 +- extras/basic_example/public/quality_layers.js | 20 +- nuve/nuveAPI/auth/nuveAuthenticator.js | 12 +- nuve/nuveAPI/cloudHandler.js | 18 +- nuve/nuveAPI/logger.js | 6 +- nuve/nuveAPI/mdb/erizoControllerRegistry.js | 2 +- nuve/nuveAPI/resource/roomResource.js | 2 +- nuve/nuveAPI/resource/tokensResource.js | 4 +- nuve/nuveAPI/resource/userResource.js | 2 +- nuve/nuveAPI/rpc/rpc.js | 10 +- nuve/nuveAPI/rpc/rpcPublic.js | 2 +- nuve/nuveAPI/test/auth/mauthParser.js | 8 +- nuve/nuveAPI/test/auth/nuveAuthenticator.js | 6 +- .../test/ch_policies/default_policy.js | 4 +- .../test/mdb/erizoControllerRegistry.js | 2 +- nuve/nuveAPI/test/utils.js | 2 +- package.json | 2 +- 43 files changed, 407 insertions(+), 422 deletions(-) diff --git a/erizo_controller/ROV/rovClient.js b/erizo_controller/ROV/rovClient.js index c980894ef4..1e77d406ce 100644 --- a/erizo_controller/ROV/rovClient.js +++ b/erizo_controller/ROV/rovClient.js @@ -6,7 +6,6 @@ const logger = require('./../common/logger').logger; const log = logger.getLogger('RovClient'); class NuveProxy { - constructor(amqper) { this.amqper = amqper; } @@ -31,7 +30,6 @@ class NuveProxy { getErizoControllers() { return this.callNuve('getErizoControllers', [], undefined); } - } class RovConnection { diff --git a/erizo_controller/ROV/rovMetricsServer.js b/erizo_controller/ROV/rovMetricsServer.js index 32cc77328a..8898109109 100644 --- a/erizo_controller/ROV/rovMetricsServer.js +++ b/erizo_controller/ROV/rovMetricsServer.js @@ -74,9 +74,9 @@ amqper.connect(() => { rovMetricsGatherer.gatherMetrics().then(() => { log.debug('Gathered licode metrics'); }) - .catch((error) => { - log.error('Error gathering metrics', error); - }); + .catch((error) => { + log.error('Error gathering metrics', error); + }); }, config.rov.statsPeriod); server.get('/metrics', (req, res) => { res.set('Content-Type', register.contentType); diff --git a/erizo_controller/common/amqper.js b/erizo_controller/common/amqper.js index 7a442225bf..a83f0bbd2b 100644 --- a/erizo_controller/common/amqper.js +++ b/erizo_controller/common/amqper.js @@ -17,7 +17,7 @@ const TIMEOUT = 5000; // This timeout shouldn't be too low because it won't listen to onReady responses from ErizoJS const REMOVAL_TIMEOUT = 300000; -const map = {}; // {corrID: {fn: callback, to: timeout}} +const map = {}; // {corrID: {fn: callback, to: timeout}} let connection; let rpcExc; let broadcastExc; @@ -43,15 +43,15 @@ exports.setPublicRPC = (methods) => { }; exports.connect = (callback) => { - // Create the amqp connection to rabbitMQ server + // Create the amqp connection to rabbitMQ server connection = amqp.createConnection(addr); connection.on('ready', () => { - // Create a direct exchange + // Create a direct exchange rpcExc = connection.exchange('rpcExchange', { type: 'direct' }, (exchange) => { try { log.info(`message: rpcExchange open, exchangeName: ${exchange.name}`); - // Create the queue for receiving messages + // Create the queue for receiving messages clientQueue = connection.queue('', (q) => { log.info(`message: clientqueue open, queuename: ${q.name}`); @@ -59,14 +59,11 @@ exports.connect = (callback) => { clientQueue.subscribe((message) => { try { - log.debug('message: message received, ' + - `queueName: ${clientQueue.name}`, + log.debug(`message: message received, queueName: ${clientQueue.name}`, logger.objectToLog(message)); if (map[message.corrID] !== undefined) { - log.debug('message: Callback, ' + - `queueName: ${clientQueue.name}, ` + - `messageType: ${message.type}`, + log.debug(`message: Callback, queueName: ${clientQueue.name}, messageType: ${message.type}`, logger.objectToLog(message.data)); clearTimeout(map[message.corrID].to); @@ -93,12 +90,12 @@ exports.connect = (callback) => { } }); - // Create a fanout exchange + // Create a fanout exchange broadcastExc = connection.exchange('broadcastExchange', - { type: 'topic', autoDelete: false }, - (exchange) => { - log.info(`message: exchange open, exchangeName: ${exchange.name}`); - }); + { type: 'topic', autoDelete: false }, + (exchange) => { + log.info(`message: exchange open, exchangeName: ${exchange.name}`); + }); }); connection.on('error', (e) => { @@ -109,7 +106,7 @@ exports.connect = (callback) => { }; exports.bind = (id, callback) => { - // Create the queue for receive messages + // Create the queue for receive messages const q = connection.queue(id, () => { try { log.info(`message: queue open, queueName: ${q.name}`); @@ -117,13 +114,12 @@ exports.bind = (id, callback) => { q.bind('rpcExchange', id, callback); q.subscribe((message) => { try { - log.debug('message: message received, ' + - `queueName: ${q.name}, `, + log.debug(`message: message received, queueName: ${q.name}, `, logger.objectToLog(message)); message.args = message.args || []; message.args.push((type, result) => { rpcExc.publish(message.replyTo, - { data: result, corrID: message.corrID, type }); + { data: result, corrID: message.corrID, type }); }); rpcPublic[message.method](...message.args); } catch (error) { @@ -140,7 +136,7 @@ exports.bind = (id, callback) => { // Subscribe to 'topic' exports.bindBroadcast = (id, callback) => { - // Create the queue for receive messages + // Create the queue for receive messages const q = connection.queue('', () => { try { log.info(`message: broadcast queue open, queueName: ${q.name}`); diff --git a/erizo_controller/common/logger.js b/erizo_controller/common/logger.js index da6a1e0229..334d4133d6 100644 --- a/erizo_controller/common/logger.js +++ b/erizo_controller/common/logger.js @@ -34,7 +34,7 @@ exports.logger.objectToLog = (jsonInput) => { } const jsonString = JSON.stringify(jsonInput, logJsonReplacer); return jsonString.replace(/['"]+/g, '') - .replace(/[:]+/g, ': ') - .replace(/[,]+/g, ', ') - .slice(1, -1); + .replace(/[:]+/g, ': ') + .replace(/[,]+/g, ', ') + .slice(1, -1); }; diff --git a/erizo_controller/common/semanticSdp/CandidateInfo.js b/erizo_controller/common/semanticSdp/CandidateInfo.js index fbf4a0407f..7c6771cb38 100755 --- a/erizo_controller/common/semanticSdp/CandidateInfo.js +++ b/erizo_controller/common/semanticSdp/CandidateInfo.js @@ -15,7 +15,7 @@ class CandidateInfo { clone() { return new CandidateInfo(this.foundation, this.componentId, this.transport, this.priority, - this.address, this.port, this.type, this.generation, this.relAddr, this.relPort); + this.address, this.port, this.type, this.generation, this.relAddr, this.relPort); } plain() { @@ -73,7 +73,6 @@ class CandidateInfo { getRelPort() { return this.relPort; } - } module.exports = CandidateInfo; diff --git a/erizo_controller/common/semanticSdp/CodecInfo.js b/erizo_controller/common/semanticSdp/CodecInfo.js index d4b468187b..257dc57ed1 100755 --- a/erizo_controller/common/semanticSdp/CodecInfo.js +++ b/erizo_controller/common/semanticSdp/CodecInfo.js @@ -1,5 +1,4 @@ class CodecInfo { - constructor(codec, type, rate, encoding, params, feedback) { this.codec = codec; this.type = type; diff --git a/erizo_controller/common/semanticSdp/ICEInfo.js b/erizo_controller/common/semanticSdp/ICEInfo.js index b52fc89dcc..dbc9c68fb6 100755 --- a/erizo_controller/common/semanticSdp/ICEInfo.js +++ b/erizo_controller/common/semanticSdp/ICEInfo.js @@ -73,7 +73,6 @@ class ICEInfo { setEndOfCandidates(endOfCandidates) { this.endOfCandidates = endOfCandidates; } - } ICEInfo.generate = () => { diff --git a/erizo_controller/common/semanticSdp/SDPInfo.js b/erizo_controller/common/semanticSdp/SDPInfo.js index 4c78f21f11..ae87078ed2 100755 --- a/erizo_controller/common/semanticSdp/SDPInfo.js +++ b/erizo_controller/common/semanticSdp/SDPInfo.js @@ -324,8 +324,8 @@ class SDPInfo { md.fmtp.push({ payload: codec.getType(), config: Object.keys(params) - .map(item => item + (params[item] ? `=${params[item]}` : '')) - .join(';'), + .map(item => item + (params[item] ? `=${params[item]}` : '')) + .join(';'), }); } diff --git a/erizo_controller/erizoAgent/erizoAgent.js b/erizo_controller/erizoAgent/erizoAgent.js index 0b664dcf45..e206b29bfd 100644 --- a/erizo_controller/erizoAgent/erizoAgent.js +++ b/erizo_controller/erizoAgent/erizoAgent.js @@ -164,7 +164,7 @@ const launchErizoJS = (erizo) => { fs.close(out, (message) => { if (message) { log.error('message: error closing log file, ', - `erizoId: ${id}`, 'error:', message); + `erizoId: ${id}`, 'error:', message); } }); } @@ -173,7 +173,7 @@ const launchErizoJS = (erizo) => { fs.close(err, (message) => { if (message) { log.error('message: error closing log file, ', - `erizoId: ${id}`, 'error:', message); + `erizoId: ${id}`, 'error:', message); } }); } diff --git a/erizo_controller/erizoController/ecCloudHandler.js b/erizo_controller/erizoController/ecCloudHandler.js index 47a505be2c..d5295644a4 100644 --- a/erizo_controller/erizoController/ecCloudHandler.js +++ b/erizo_controller/erizoController/ecCloudHandler.js @@ -67,7 +67,7 @@ exports.EcCloudHandler = (spec) => { if (global.config.erizoController.cloudHandlerPolicy) { // eslint-disable-next-line global-require, import/no-dynamic-require getErizoAgent = require(`./ch_policies/${ - global.config.erizoController.cloudHandlerPolicy}`).getErizoAgent; + global.config.erizoController.cloudHandlerPolicy}`).getErizoAgent; } const tryAgain = (count, callback) => { diff --git a/erizo_controller/erizoController/erizoController.js b/erizo_controller/erizoController/erizoController.js index 555d4672fa..31e55d1190 100644 --- a/erizo_controller/erizoController/erizoController.js +++ b/erizo_controller/erizoController/erizoController.js @@ -138,7 +138,7 @@ if (global.config.erizoController.listen_ssl) { } server.listen(global.config.erizoController.listen_port); - // eslint-disable-next-line global-require, import/no-extraneous-dependencies +// eslint-disable-next-line global-require, import/no-extraneous-dependencies const io = require('socket.io').listen(server, { log: false }); io.set('transports', ['websocket']); @@ -193,8 +193,8 @@ const addToCloudHandler = (callback) => { .then(() => true) .catch((result) => { if (result === 'whoareyou') { - // TODO: It should try to register again in Cloud Handler. - // But taking into account current rooms, users, ... + // TODO: It should try to register again in Cloud Handler. + // But taking into account current rooms, users, ... log.error('message: This ErizoController does not exist in cloudHandler ' + 'to avoid unexpected behavior this ErizoController will die'); clearInterval(intervalId); @@ -242,7 +242,7 @@ const addToCloudHandler = (callback) => { log.warn('message: addECToCloudHandler cloudHandler does not respond, ' + `attemptsLeft: ${attempt}`); - // We'll try it more! + // We'll try it more! setTimeout(() => { attempt -= 1; addECToCloudHandler(attempt); diff --git a/erizo_controller/erizoController/models/Channel.js b/erizo_controller/erizoController/models/Channel.js index e81cc041b4..2617046678 100644 --- a/erizo_controller/erizoController/models/Channel.js +++ b/erizo_controller/erizoController/models/Channel.js @@ -143,7 +143,7 @@ class Channel extends events.EventEmitter { return; } log.debug('message: sending buffered messages, number:', buffer.length, - ', channelId:', this.id); + ', channelId:', this.id); buffer.forEach((message) => { log.debug('message: sending buffered message, message:', message, ', channelId:', this.id); this.sendMessage(...message); @@ -155,7 +155,6 @@ class Channel extends events.EventEmitter { clearTimeout(this.disconnecting); this.socket.disconnect(); } - } exports.Channel = Channel; diff --git a/erizo_controller/erizoController/models/Client.js b/erizo_controller/erizoController/models/Client.js index 1908777632..b6a1d582ca 100644 --- a/erizo_controller/erizoController/models/Client.js +++ b/erizo_controller/erizoController/models/Client.js @@ -425,7 +425,7 @@ class Client extends events.EventEmitter { _publishErizo(id, options, sdp, callback) { options.mediaConfiguration = this.token.mediaConfiguration; options.singlePC = this.options.singlePC || false; - log.info('message: addPublisher requested, ' + + log.info('message: addPublisher requested, ', `streamId: ${id}, clientId: ${this.id}`, logger.objectToLog(options), logger.objectToLog(options.attributes)); @@ -552,9 +552,9 @@ class Client extends events.EventEmitter { const stream = this.room.streamManager.getPublishedStreamById(options.streamId); if (stream === undefined) { - log.warn('message: addSubscriber can not be requested, ' + - 'reason: publisher not found' + - `streamId: ${options.streamId}, ` + + log.warn('message: addSubscriber can not be requested, ', + 'reason: publisher not found', + `streamId: ${options.streamId}, `, `clientId: ${this.id},`, logger.objectToLog(options), logger.objectToLog(options.metadata)); @@ -573,9 +573,9 @@ class Client extends events.EventEmitter { client.sendMessage('publish_me', { streamId: options.streamId, peerSocket: this.id }); } else { if (stream.hasAvSubscriber(this.id)) { - log.warn('message: addSubscriber can not be requested, ' + - 'reason: this client is already subscribed' + - `streamId: ${options.streamId}, ` + + log.warn('message: addSubscriber can not be requested, ', + 'reason: this client is already subscribed', + `streamId: ${options.streamId}, `, `clientId: ${this.id},`, logger.objectToLog(options), logger.objectToLog(options.metadata)); @@ -607,7 +607,7 @@ class Client extends events.EventEmitter { } return; } else if (signMess.type === 'failed') { - // TODO: Add Stats event + // TODO: Add Stats event log.warn('message: addSubscriber ICE Failed, ' + 'state: SUBSCRIBER_FAILED, ' + `streamId: ${options.streamId}, ` + @@ -927,7 +927,6 @@ class Client extends events.EventEmitter { }); } } - } exports.Client = Client; diff --git a/erizo_controller/erizoController/models/Room.js b/erizo_controller/erizoController/models/Room.js index 302753ee9b..a3e766ba4d 100644 --- a/erizo_controller/erizoController/models/Room.js +++ b/erizo_controller/erizoController/models/Room.js @@ -67,13 +67,13 @@ class Room extends events.EventEmitter { onRoomControllerEvent(type, evt) { if (type === 'unpublish') { - // It's supposed to be an integer. + // It's supposed to be an integer. const streamId = parseInt(evt, 10); log.warn('message: Triggering removal of stream ' + 'because of ErizoJS timeout, ' + `streamId: ${streamId}`); this.sendMessage('onRemoveStream', { id: streamId }); - // remove clients and streams? + // remove clients and streams? } } @@ -87,9 +87,9 @@ class Room extends events.EventEmitter { sendMessage(method, args) { this.forEachClient((client) => { log.debug('message: sendMsgToRoom,', - 'clientId:', client.id, ',', - 'roomId:', this.id, ', ', - logger.objectToLog(method)); + 'clientId:', client.id, ',', + 'roomId:', this.id, ', ', + logger.objectToLog(method)); client.sendMessage(method, args); }); } diff --git a/erizo_controller/erizoController/roomController.js b/erizo_controller/erizoController/roomController.js index 71c7783a68..db41884585 100644 --- a/erizo_controller/erizoController/roomController.js +++ b/erizo_controller/erizoController/roomController.js @@ -15,7 +15,7 @@ exports.RoomController = (spec) => { const maxErizosUsedByRoom = spec.maxErizosUsedByRoom || global.config.erizoController.maxErizosUsedByRoom; const erizos = new ErizoList(maxErizosUsedByRoom); - // {id: ExternalOutput} + // {id: ExternalOutput} const amqper = spec.amqper; const ecch = spec.ecch; const erizoControllerId = spec.erizoControllerId; @@ -178,7 +178,7 @@ exports.RoomController = (spec) => { amqper.callRpc(getErizoQueueFromErizoId(erizoId), 'processStreamMessage', args, {}); }; - /* + /* * Adds a publisher to the room. This creates a new OneToManyProcessor * and a new WebRtcConnection. This WebRtcConnection will be the publisher * of the OneToManyProcessor. @@ -189,11 +189,11 @@ exports.RoomController = (spec) => { } if (streamManager.getPublishedStreamState(streamId) === StreamStates.PUBLISHER_CREATED) { - log.info('message: addPublisher, ' + - `clientId ${clientId}, ` + - `streamId: ${streamId}`, - logger.objectToLog(options), - logger.objectToLog(options.metadata)); + log.info('message: addPublisher, ', + `clientId ${clientId}, `, + `streamId: ${streamId}`, + logger.objectToLog(options), + logger.objectToLog(options.metadata)); // We create a new ErizoJS with the streamId. getErizoJS((erizoId, agentId) => { @@ -203,11 +203,11 @@ exports.RoomController = (spec) => { callback('timeout-agent'); return; } - log.info('message: addPublisher erizoJs assigned, ' + - `erizoId: ${erizoId}, streamId: ${streamId}`, - logger.objectToLog(options.metadata)); - // Track publisher locally - // then we call its addPublisher method. + log.info('message: addPublisher erizoJs assigned, ', + `erizoId: ${erizoId}, streamId: ${streamId}`, + logger.objectToLog(options.metadata)); + // Track publisher locally + // then we call its addPublisher method. const args = [erizoControllerId, clientId, streamId, options]; streamManager.updateErizoIdForPublishedStream(streamId, erizoId); @@ -215,21 +215,21 @@ exports.RoomController = (spec) => { { callback: (data) => { if (data === 'timeout') { if (retries < MAX_ERIZOJS_RETRIES) { - log.warn('message: addPublisher ErizoJS timeout, ' + - `streamId: ${streamId}, ` + - `erizoId: ${getErizoQueueFromStreamId(streamId)}, ` + - `retries: ${retries}, `, - logger.objectToLog(options.metadata)); + log.warn('message: addPublisher ErizoJS timeout, ', + `streamId: ${streamId}, `, + `erizoId: ${getErizoQueueFromStreamId(streamId)}, `, + `retries: ${retries}, `, + logger.objectToLog(options.metadata)); retries += 1; callback('timeout-erizojs-retry'); streamManager.updateErizoIdForPublishedStream(streamId, null); that.addPublisher(clientId, streamId, options, callback, retries); return; } - log.warn('message: addPublisher ErizoJS timeout no retry, ' + - `retries: ${retries}, streamId: ${streamId}, ` + - `erizoId: ${getErizoQueueFromStreamId(streamId)},`, - logger.objectToLog(options.metadata)); + log.warn('message: addPublisher ErizoJS timeout no retry, ', + `retries: ${retries}, streamId: ${streamId}, `, + `erizoId: ${getErizoQueueFromStreamId(streamId)},`, + logger.objectToLog(options.metadata)); streamManager.updateErizoIdForPublishedStream(streamId, null); callback('timeout-erizojs'); } else { @@ -248,17 +248,17 @@ exports.RoomController = (spec) => { } }; - /* + /* * Adds a subscriber to the room. This creates a new WebRtcConnection. * This WebRtcConnection will be added to the subscribers list of the * OneToManyProcessor. */ that.addSubscriber = (clientId, streamId, options, callback, retries) => { if (clientId === null) { - log.warn('message: addSubscriber null clientId, ' + - `streamId: ${streamId}, ` + - `clientId: ${clientId},`, - logger.objectToLog(options.metadata)); + log.warn('message: addSubscriber null clientId, ', + `streamId: ${streamId}, `, + `clientId: ${clientId},`, + logger.objectToLog(options.metadata)); callback('Error: null clientId'); return; } @@ -267,8 +267,8 @@ exports.RoomController = (spec) => { if (streamManager .getPublishedStreamById(streamId) .getAvSubscriberState(clientId) === StreamStates.SUBSCRIBER_CREATED) { - log.info('message: addSubscriber, ' + - `streamId: ${streamId}, ` + + log.info('message: addSubscriber, ', + `streamId: ${streamId}, `, `clientId: ${clientId},`, logger.objectToLog(options), logger.objectToLog(options.metadata)); @@ -281,9 +281,9 @@ exports.RoomController = (spec) => { amqper.callRpc(getErizoQueueFromStreamId(streamId), 'addSubscriber', args, { callback: (data) => { if (!streamManager.hasPublishedStream(streamId)) { - log.warn('message: addSubscriber rpc callback has arrived after ' + - 'publisher is removed, ' + - `streamId: ${streamId}, ` + + log.warn('message: addSubscriber rpc callback has arrived after ', + 'publisher is removed, ', + `streamId: ${streamId}, `, `clientId: ${clientId},`, logger.objectToLog(options.metadata)); callback('timeout'); @@ -292,25 +292,25 @@ exports.RoomController = (spec) => { if (data === 'timeout') { if (retries < MAX_ERIZOJS_RETRIES) { retries += 1; - log.warn('message: addSubscriber ErizoJS timeout, ' + - `clientId: ${clientId}, ` + - `streamId: ${streamId}, ` + - `erizoId: ${getErizoQueueFromStreamId(streamId)}, ` + + log.warn('message: addSubscriber ErizoJS timeout, ', + `clientId: ${clientId}, `, + `streamId: ${streamId}, `, + `erizoId: ${getErizoQueueFromStreamId(streamId)}, `, `retries: ${retries},`, logger.objectToLog(options.metadata)); that.addSubscriber(clientId, streamId, options, callback, retries); return; } - log.error('message: addSubscriber ErizoJS timeout no retry, ' + - `clientId: ${clientId}, ` + - `streamId: ${streamId}, ` + + log.error('message: addSubscriber ErizoJS timeout no retry, ', + `clientId: ${clientId}, `, + `streamId: ${streamId}, `, `erizoId: ${getErizoQueueFromStreamId(streamId)},`, logger.objectToLog(options.metadata)); callback('timeout'); return; } - log.info('message: addSubscriber finished, ' + - `streamId: ${streamId}, ` + + log.info('message: addSubscriber finished, ', + `streamId: ${streamId}, `, `clientId: ${clientId},`, logger.objectToLog(options), logger.objectToLog(options.metadata)); @@ -325,10 +325,10 @@ exports.RoomController = (spec) => { that.addMultipleSubscribers = (clientId, streamIds, options, callback, retries) => { if (clientId === null) { - log.warn('message: addMultipleSubscribers null clientId, ' + - `streams: ${streamIds.length}, ` + - `clientId: ${clientId},`, - logger.objectToLog(options.metadata)); + log.warn('message: addMultipleSubscribers null clientId, ', + `streams: ${streamIds.length}, `, + `clientId: ${clientId},`, + logger.objectToLog(options.metadata)); callback('Error: null clientId'); return; } @@ -347,36 +347,36 @@ exports.RoomController = (spec) => { const streamIdsInErizo = streamIds.filter(streamId => getErizoQueueFromStreamId(streamId) === erizoId); const args = [erizoControllerId, clientId, streamIdsInErizo, options]; - log.info('message: addMultipleSubscribers, ' + - `streams: ${streamIdsInErizo}, ` + - `clientId: ${clientId},`, - logger.objectToLog(options), - logger.objectToLog(options.metadata)); + log.info('message: addMultipleSubscribers, ', + `streams: ${streamIdsInErizo}, `, + `clientId: ${clientId},`, + logger.objectToLog(options), + logger.objectToLog(options.metadata)); amqper.callRpc(erizoId, 'addMultipleSubscribers', args, { callback: (data) => { if (data === 'timeout') { if (retries < MAX_ERIZOJS_RETRIES) { retries += 1; - log.warn('message: addMultipleSubscribers ErizoJS timeout, ' + - `clientId: ${clientId}, ` + - `streams: ${streamIdsInErizo}, ` + - `erizoId: ${erizoId}, ` + + log.warn('message: addMultipleSubscribers ErizoJS timeout, ', + `clientId: ${clientId}, `, + `streams: ${streamIdsInErizo}, `, + `erizoId: ${erizoId}, `, `retries: ${retries},`, logger.objectToLog(options.metadata)); that.addMultipleSubscribers(clientId, streamIdsInErizo, options, callback, retries); return; } - log.warn('message: addMultipleSubscribers ErizoJS timeout no retry, ' + - `clientId: ${clientId}, ` + - `streams: ${streamIdsInErizo.length}, ` + + log.warn('message: addMultipleSubscribers ErizoJS timeout no retry, ', + `clientId: ${clientId}, `, + `streams: ${streamIdsInErizo.length}, `, `erizoId: ${erizoId},`, logger.objectToLog(options.metadata)); callback('timeout'); return; } - log.info('message: addMultipleSubscribers finished, ' + - `streams: ${streamIdsInErizo}, ` + + log.info('message: addMultipleSubscribers finished, ', + `streams: ${streamIdsInErizo}, `, `clientId: ${clientId},`, logger.objectToLog(options), logger.objectToLog(options.metadata)); @@ -387,7 +387,7 @@ exports.RoomController = (spec) => { }); }; - /* + /* * Removes a publisher from the room. This also deletes the associated OneToManyProcessor. */ that.removePublisher = (clientId, streamId, callback) => { @@ -407,7 +407,7 @@ exports.RoomController = (spec) => { } }); }; - /* + /* * Removes a subscriber from the room. * This also removes it from the associated OneToManyProcessor. */ diff --git a/erizo_controller/erizoJS/adapt_schemes/notify-break-recover.js b/erizo_controller/erizoJS/adapt_schemes/notify-break-recover.js index 932e5c290a..ef401c9696 100644 --- a/erizo_controller/erizoJS/adapt_schemes/notify-break-recover.js +++ b/erizo_controller/erizoJS/adapt_schemes/notify-break-recover.js @@ -106,9 +106,9 @@ exports.MonitorSubscriber = (log) => { `averageBandwidth: ${average}, ` + `lowerThreshold: ${mediaStream.lowerThres}`); mediaStream.bwStatus = BW_WONTRECOVER; - } else if (nextRetry === 0) { // schedule next retry + } else if (nextRetry === 0) { // schedule next retry nextRetry = tics + 20; - } else if ((tics += 1) === nextRetry) { // next retry is in order + } else if ((tics += 1) === nextRetry) { // next retry is in order mediaStream.bwStatus = BW_RECOVERING; ticsToTry = tics + 10; mediaStream.setFeedbackReports(false, average); diff --git a/erizo_controller/erizoJS/erizoJSController.js b/erizo_controller/erizoJS/erizoJSController.js index d4f865c49a..bd00b18ecc 100644 --- a/erizo_controller/erizoJS/erizoJSController.js +++ b/erizo_controller/erizoJS/erizoJSController.js @@ -85,7 +85,7 @@ exports.ErizoJSController = (erizoJSId, threadPool, ioThreadPool) => { }; const onConnectionStatusEvent = (erizoControllerId, clientId, - connectionId, connectionEvent, newStatus) => { + connectionId, connectionEvent, newStatus) => { const rpcID = `erizoController_${erizoControllerId}`; amqper.callRpc(rpcID, 'connectionStatusEvent', [clientId, connectionId, newStatus, connectionEvent]); @@ -185,7 +185,7 @@ exports.ErizoJSController = (erizoJSId, threadPool, ioThreadPool) => { }; that.processConnectionMessage = (erizoControllerId, clientId, connectionId, msg, - callbackRpc = () => {}) => { + callbackRpc = () => {}) => { log.info('message: Process Connection message, ' + `clientId: ${clientId}, connectionId: ${connectionId}`); let error; @@ -258,8 +258,8 @@ exports.ErizoJSController = (erizoJSId, threadPool, ioThreadPool) => { // eslint-disable-next-line no-param-reassign options.privateRegexp = that.privateRegexp; const connection = client.getOrCreateConnection(options); - log.info('message: Adding publisher, ' + - `clientId: ${clientId}, ` + + log.info('message: Adding publisher, ', + `clientId: ${clientId}, `, `streamId: ${streamId}`, logger.objectToLog(options), logger.objectToLog(options.metadata)); @@ -294,7 +294,7 @@ exports.ErizoJSController = (erizoJSId, threadPool, ioThreadPool) => { } else { publisher = publishers[streamId]; if (publisher.numSubscribers === 0) { - log.warn('message: publisher already set but no subscribers will ignore, ' + + log.warn('message: publisher already set but no subscribers will ignore, ', `code: ${WARN_CONFLICT}, streamId: ${streamId}`, logger.objectToLog(options.metadata)); } else { @@ -313,8 +313,8 @@ exports.ErizoJSController = (erizoJSId, threadPool, ioThreadPool) => { updateUptimeInfo(); const publisher = publishers[streamId]; if (publisher === undefined) { - log.warn('message: addSubscriber to unknown publisher, ' + - `code: ${WARN_NOT_FOUND}, streamId: ${streamId}, ` + + log.warn('message: addSubscriber to unknown publisher, ', + `code: ${WARN_NOT_FOUND}, streamId: ${streamId}, `, `clientId: ${clientId}`, logger.objectToLog(options.metadata)); // We may need to notify the clients @@ -377,22 +377,22 @@ exports.ErizoJSController = (erizoJSId, threadPool, ioThreadPool) => { } const knownPublishers = streamIds.map(streamId => publishers[streamId]) - .filter(pub => - pub !== undefined && + .filter(pub => + pub !== undefined && !pub.getSubscriber(clientId)); if (knownPublishers.length === 0) { - log.warn('message: addMultipleSubscribers to unknown publisher, ' + - `code: ${WARN_NOT_FOUND}, streamIds: ${streamIds}, ` + + log.warn('message: addMultipleSubscribers to unknown publisher, ', + `code: ${WARN_NOT_FOUND}, streamIds: ${streamIds}, `, `clientId: ${clientId}`, logger.objectToLog(options.metadata)); callbackRpc('callback', { type: 'error' }); return; } - log.debug('message: addMultipleSubscribers to publishers, ' + - `streamIds: ${knownPublishers}, ` + - `clientId: ${clientId}`, - logger.objectToLog(options.metadata)); + log.debug('message: addMultipleSubscribers to publishers, ', + `streamIds: ${knownPublishers}, `, + `clientId: ${clientId}`, + logger.objectToLog(options.metadata)); const client = getOrCreateClient(erizoControllerId, clientId, options.singlePC); // eslint-disable-next-line no-param-reassign @@ -434,13 +434,13 @@ exports.ErizoJSController = (erizoJSId, threadPool, ioThreadPool) => { }); }; - /* + /* * Removes multiple subscribers from the room. */ that.removeMultipleSubscribers = (clientId, streamIds, callbackRpc) => { const knownPublishers = streamIds.map(streamId => publishers[streamId]) - .filter(pub => - pub !== undefined && + .filter(pub => + pub !== undefined && pub.getSubscriber(clientId)); if (knownPublishers.length === 0) { log.warn('message: removeMultipleSubscribers from unknown publisher, ' + @@ -502,7 +502,7 @@ exports.ErizoJSController = (erizoJSId, threadPool, ioThreadPool) => { delete publishers[streamId]; closeNode(publisher).then(() => { publisher.muxer.close((message) => { - log.info('message: muxer closed succesfully, ' + + log.info('message: muxer closed succesfully, ', `id: ${streamId}`, logger.objectToLog(message)); const count = Object.keys(publishers).length; diff --git a/erizo_controller/erizoJS/models/Client.js b/erizo_controller/erizoJS/models/Client.js index b7e0247f38..283844a90f 100644 --- a/erizo_controller/erizoJS/models/Client.js +++ b/erizo_controller/erizoJS/models/Client.js @@ -6,7 +6,6 @@ const EventEmitter = require('events').EventEmitter; const log = logger.getLogger('Client'); class Client extends EventEmitter { - constructor(erizoControllerId, erizoJSId, id, threadPool, ioThreadPool, singlePc = false) { super(); log.info(`Constructor Client ${id}`); diff --git a/erizo_controller/erizoJS/models/Connection.js b/erizo_controller/erizoJS/models/Connection.js index e28db648af..94424b13e2 100644 --- a/erizo_controller/erizoJS/models/Connection.js +++ b/erizo_controller/erizoJS/models/Connection.js @@ -244,7 +244,7 @@ class Connection extends events.EventEmitter { this.sessionVersion = 0; this.wrtc.init((newStatus, mess) => { - log.info('message: WebRtcConnection status update, ' + + log.info('message: WebRtcConnection status update, ', `id: ${this.id}, status: ${newStatus}`, logger.objectToLog(this.metadata)); switch (newStatus) { @@ -348,12 +348,12 @@ class Connection extends events.EventEmitter { onEvent = this.onGathered; } return this.processOffer(msg.sdp) - .then(() => onEvent) - .then(() => { - this.sendAnswer(); - }).catch(() => { - log.error('message: Error processing offer/answer in connection, connectionId:', this.id); - }); + .then(() => onEvent) + .then(() => { + this.sendAnswer(); + }).catch(() => { + log.error('message: Error processing offer/answer in connection, connectionId:', this.id); + }); } else if (msg.type === 'offer-noanswer') { return this.processOffer(msg.sdp).catch(() => { log.error('message: Error processing offer/noanswer in connection, connectionId:', this.id); @@ -408,6 +408,5 @@ class Connection extends events.EventEmitter { delete this.wrtc; }); } - } exports.Connection = Connection; diff --git a/erizo_controller/erizoJS/models/Node.js b/erizo_controller/erizoJS/models/Node.js index 44379ab462..e8ebbc561e 100644 --- a/erizo_controller/erizoJS/models/Node.js +++ b/erizo_controller/erizoJS/models/Node.js @@ -63,11 +63,11 @@ class Node extends EventEmitter { monitorMinVideoBw = require(`../adapt_schemes/${mediaStream.scheme}`) .MonitorSubscriber(log); } catch (e) { - log.warn('message: could not find custom adapt scheme, ' + - `code: ${WARN_PRECOND_FAILED}, ` + - `id:${this.clientId}, ` + - `scheme: ${mediaStream.scheme},`, - logger.objectToLog(this.options.metadata)); + log.warn('message: could not find custom adapt scheme,', + `code: ${WARN_PRECOND_FAILED},`, + `id:${this.clientId},`, + `scheme: ${mediaStream.scheme},`, + logger.objectToLog(this.options.metadata)); } } else { // eslint-disable-next-line global-require diff --git a/erizo_controller/erizoJS/models/Publisher.js b/erizo_controller/erizoJS/models/Publisher.js index 740b5cfcde..9936597d2c 100644 --- a/erizo_controller/erizoJS/models/Publisher.js +++ b/erizo_controller/erizoJS/models/Publisher.js @@ -44,8 +44,8 @@ class Source extends NodeClass { addSubscriber(clientId, connection, options) { log.info(`message: Adding subscriber, clientId: ${clientId}, streamId ${this.streamId}`, - logger.objectToLog(options), - logger.objectToLog(options.metadata)); + logger.objectToLog(options), + logger.objectToLog(options.metadata)); const subscriber = new Subscriber(clientId, this.streamId, connection, this, options); this.subscribers[clientId] = subscriber; @@ -56,9 +56,8 @@ class Source extends NodeClass { this._onSchemeSlideShowModeChange.bind(this, clientId); subscriber.on('scheme-slideshow-change', subscriber._onSchemeSlideShowModeChangeListener); - log.debug('message: Setting scheme from publisher to subscriber, ' + - `clientId: ${clientId}, scheme: ${this.scheme}`, - logger.objectToLog(options.metadata)); + log.debug(`message: Setting scheme from publisher to subscriber, clientId: ${clientId}, scheme: ${this.scheme}`, + logger.objectToLog(options.metadata)); subscriber.mediaStream.scheme = this.scheme; const muteVideo = (options.muteStream && options.muteStream.video) || false; @@ -303,7 +302,7 @@ class Source extends NodeClass { return; } log.info('message: setQualityLayer, spatialLayer: ', qualityLayer.spatialLayer, - ', temporalLayer: ', qualityLayer.temporalLayer); + ', temporalLayer: ', qualityLayer.temporalLayer); subscriber.mediaStream.setQualityLayer(qualityLayer.spatialLayer, qualityLayer.temporalLayer); } @@ -323,9 +322,9 @@ class Source extends NodeClass { subscriber.muteVideo = muteVideo; subscriber.muteAudio = muteAudio; log.info('message: Mute Subscriber Stream, video: ', this.muteVideo || muteVideo, - ', audio: ', this.muteAudio || muteAudio); + ', audio: ', this.muteAudio || muteAudio); subscriber.mediaStream.muteStream(this.muteVideo || muteVideo, - this.muteAudio || muteAudio); + this.muteAudio || muteAudio); } setVideoConstraints(video, clientId) { diff --git a/erizo_controller/erizoJS/models/SessionDescription.js b/erizo_controller/erizoJS/models/SessionDescription.js index 1802f90392..4c36ae806a 100644 --- a/erizo_controller/erizoJS/models/SessionDescription.js +++ b/erizo_controller/erizoJS/models/SessionDescription.js @@ -2,7 +2,7 @@ // eslint-disable-next-line import/no-unresolved const ConnectionDescription = require('./../../../erizoAPI/build/Release/addon') - .ConnectionDescription; + .ConnectionDescription; const SdpInfo = require('./../../common/semanticSdp/SDPInfo'); const MediaInfo = require('./../../common/semanticSdp/MediaInfo'); const ICEInfo = require('./../../common/semanticSdp/ICEInfo'); @@ -262,7 +262,7 @@ class SessionDescription { let audio; let video; - info.setRtcpMux(true); // TODO + info.setRtcpMux(true); // TODO // we use the same field for both audio and video if (sdp.medias && sdp.medias.length > 0) { @@ -277,7 +277,7 @@ class SessionDescription { info.setProfile('UDP/TLS/RTP/SAVPF'); // TODO - info.setBundle(true); // TODO + info.setBundle(true); // TODO const sdpDtls = sdp.getDTLS(); if (sdpDtls) { @@ -358,6 +358,5 @@ class SessionDescription { this.connectionDescription = info; } - } module.exports = SessionDescription; diff --git a/erizo_controller/test/erizoAgent/erizoAgent.js b/erizo_controller/test/erizoAgent/erizoAgent.js index eca7de29f7..2e50f3952f 100644 --- a/erizo_controller/test/erizoAgent/erizoAgent.js +++ b/erizo_controller/test/erizoAgent/erizoAgent.js @@ -1,6 +1,6 @@ /* global require, describe, it, beforeEach, afterEach */ - /* eslint-disable global-require */ +/* eslint-disable global-require */ const mocks = require('../utils'); // eslint-disable-next-line import/no-extraneous-dependencies diff --git a/erizo_controller/test/erizoController/erizoController.js b/erizo_controller/test/erizoController/erizoController.js index 028a677a4e..d201c2e25b 100644 --- a/erizo_controller/test/erizoController/erizoController.js +++ b/erizo_controller/test/erizoController/erizoController.js @@ -1,6 +1,6 @@ /* global require, describe, it, beforeEach, afterEach */ - /* eslint-disable no-unused-expressions, global-require */ +/* eslint-disable no-unused-expressions, global-require */ const mocks = require('../utils'); // eslint-disable-next-line import/no-extraneous-dependencies @@ -104,10 +104,10 @@ describe('Erizo Controller / Erizo Controller', () => { beforeEach((done) => { const callback = amqperMock.callRpc.withArgs('nuve', 'addNewErizoController') - .args[0][3].callback; + .args[0][3].callback; amqperMock.bind.withArgs(`erizoController_${arbitraryErizoControllerId}`).callsArg(1); mocks.socketIoInstance.sockets.on.withArgs('connection') - .callsArgWith(1, mocks.socketInstance); + .callsArgWith(1, mocks.socketInstance); callback({ id: arbitraryErizoControllerId }); setTimeout(() => { @@ -123,7 +123,7 @@ describe('Erizo Controller / Erizo Controller', () => { }); describe('on Token', () => { - const arbitrarySignature = 'c2lnbmF0dXJl'; // signature + const arbitrarySignature = 'c2lnbmF0dXJl'; // signature const arbitraryGoodToken = { tokenId: 'tokenId', host: 'host', @@ -154,7 +154,7 @@ describe('Erizo Controller / Erizo Controller', () => { onToken({ token: arbitraryGoodToken }, callback); expect(amqperMock.callRpc - .withArgs('nuve', 'deleteToken', arbitraryGoodToken.tokenId).callCount).to.equal(1); + .withArgs('nuve', 'deleteToken', arbitraryGoodToken.tokenId).callCount).to.equal(1); }); describe('when deleted', () => { @@ -166,8 +166,8 @@ describe('Erizo Controller / Erizo Controller', () => { onToken({ token: arbitraryGoodToken }, onTokenCallback); callback = amqperMock.callRpc - .withArgs('nuve', 'deleteToken', arbitraryGoodToken.tokenId) - .args[0][3].callback; + .withArgs('nuve', 'deleteToken', arbitraryGoodToken.tokenId) + .args[0][3].callback; }); it('should disconnect socket on Nuve error', (done) => { @@ -184,7 +184,7 @@ describe('Erizo Controller / Erizo Controller', () => { setTimeout(() => { expect(mocks.socketInstance.disconnect.callCount).to.equal(1); expect(onTokenCallback.withArgs('error', 'Nuve does not respond').callCount) - .to.equal(1); + .to.equal(1); done(); }, 0); }); @@ -215,8 +215,8 @@ describe('Erizo Controller / Erizo Controller', () => { expect(onTokenCallback.withArgs('success').callCount).to.equal(1); onToken({ token: arbitraryGoodToken }, onTokenCallback); const callback2 = amqperMock.callRpc - .withArgs('nuve', 'deleteToken', arbitraryGoodToken.tokenId) - .args[1][3].callback; + .withArgs('nuve', 'deleteToken', arbitraryGoodToken.tokenId) + .args[1][3].callback; callback2({ host: 'host', room: 'roomId' }); setTimeout(() => { expect(roomControllerMock.RoomController.callCount).to.equal(1); @@ -236,7 +236,7 @@ describe('Erizo Controller / Erizo Controller', () => { onStreamMessageErizo = mocks.socketInstance.on.withArgs('streamMessage').args[0][1]; onStreamMessageP2P = mocks.socketInstance.on.withArgs('streamMessageP2P').args[0][1]; onUpdateStreamAttributes = mocks.socketInstance.on - .withArgs('updateStreamAttributes').args[0][1]; + .withArgs('updateStreamAttributes').args[0][1]; onPublish = mocks.socketInstance.on.withArgs('publish').args[0][1]; onSubscribe = mocks.socketInstance.on.withArgs('subscribe').args[0][1]; onStartRecorder = mocks.socketInstance.on.withArgs('startRecorder').args[0][1]; @@ -253,7 +253,7 @@ describe('Erizo Controller / Erizo Controller', () => { expect(mocks.socketInstance.on.withArgs('streamMessageP2P').callCount).to.equal(1); expect(mocks.socketInstance.on.withArgs('connectionMessage').callCount).to.equal(1); expect(mocks.socketInstance.on.withArgs('updateStreamAttributes').callCount) - .to.equal(1); + .to.equal(1); expect(mocks.socketInstance.on.withArgs('publish').callCount).to.equal(1); expect(mocks.socketInstance.on.withArgs('subscribe').callCount).to.equal(1); expect(mocks.socketInstance.on.withArgs('autoSubscribe').callCount).to.equal(1); @@ -292,24 +292,24 @@ describe('Erizo Controller / Erizo Controller', () => { }); it('should not disconnect users when calling deleteUsers with an unknown room', - () => { - const aCallback = sinon.stub(); + () => { + const aCallback = sinon.stub(); - rpcPublic.deleteUser({ user: 'user', roomId: 'unknownRoomId' }, aCallback); + rpcPublic.deleteUser({ user: 'user', roomId: 'unknownRoomId' }, aCallback); - expect(aCallback.withArgs('callback', 'Success').callCount).to.equal(1); - expect(mocks.socketInstance.disconnect.callCount).to.equal(0); - }); + expect(aCallback.withArgs('callback', 'Success').callCount).to.equal(1); + expect(mocks.socketInstance.disconnect.callCount).to.equal(0); + }); it('should not disconnect users when calling deleteUsers with an unknown user', - () => { - const aCallback = sinon.stub(); + () => { + const aCallback = sinon.stub(); - rpcPublic.deleteUser({ user: 'unknownUser', roomId: 'roomId' }, aCallback); + rpcPublic.deleteUser({ user: 'unknownUser', roomId: 'roomId' }, aCallback); - expect(aCallback.withArgs('callback', 'User does not exist').callCount).to.equal(1); - expect(mocks.socketInstance.disconnect.callCount).to.equal(0); - }); + expect(aCallback.withArgs('callback', 'User does not exist').callCount).to.equal(1); + expect(mocks.socketInstance.disconnect.callCount).to.equal(0); + }); }); describe('Socket API', () => { @@ -326,7 +326,7 @@ describe('Erizo Controller / Erizo Controller', () => { onStreamMessageErizo = mocks.socketInstance.on.withArgs('streamMessage').args[0][1]; onStreamMessageP2P = mocks.socketInstance.on.withArgs('streamMessageP2P').args[0][1]; onUpdateStreamAttributes = mocks.socketInstance.on - .withArgs('updateStreamAttributes').args[0][1]; + .withArgs('updateStreamAttributes').args[0][1]; onPublish = mocks.socketInstance.on.withArgs('publish').args[0][1]; onSubscribe = mocks.socketInstance.on.withArgs('subscribe').args[0][1]; onStartRecorder = mocks.socketInstance.on.withArgs('startRecorder').args[0][1]; @@ -343,7 +343,7 @@ describe('Erizo Controller / Erizo Controller', () => { expect(mocks.socketInstance.on.withArgs('streamMessageP2P').callCount).to.equal(1); expect(mocks.socketInstance.on.withArgs('connectionMessage').callCount).to.equal(1); expect(mocks.socketInstance.on.withArgs('updateStreamAttributes').callCount) - .to.equal(1); + .to.equal(1); expect(mocks.socketInstance.on.withArgs('publish').callCount).to.equal(1); expect(mocks.socketInstance.on.withArgs('autoSubscribe').callCount).to.equal(1); expect(mocks.socketInstance.on.withArgs('unsubscribe').callCount).to.equal(1); @@ -450,7 +450,7 @@ describe('Erizo Controller / Erizo Controller', () => { onPublish(options, sdp, aCallback); expect(mocks.socketInstance.emit.withArgs('connection_failed').callCount) - .to.equal(1); + .to.equal(1); }); it('should send onAddStream event to Room when receiving ready stat', () => { @@ -473,7 +473,7 @@ describe('Erizo Controller / Erizo Controller', () => { onPublish(options, sdp, aCallback); expect(aCallback.withArgs(null, null, 'ErizoJS is not reachable').callCount) - .to.equal(1); + .to.equal(1); }); it('should emit ErizoAgent unreachable', () => { @@ -483,7 +483,7 @@ describe('Erizo Controller / Erizo Controller', () => { onPublish(options, sdp, aCallback); expect(aCallback.withArgs(null, null, 'ErizoAgent is not reachable').callCount) - .to.equal(1); + .to.equal(1); }); it('should emit ErizoJS or ErizoAgent unreachable', () => { @@ -493,7 +493,7 @@ describe('Erizo Controller / Erizo Controller', () => { onPublish(options, sdp, aCallback); expect(aCallback.withArgs(null, null, 'ErizoAgent or ErizoJS is not reachable') - .callCount).to.equal(1); + .callCount).to.equal(1); }); describe('Subscriber Connection', () => { @@ -503,7 +503,7 @@ describe('Erizo Controller / Erizo Controller', () => { let onSubscriberTokenCallback; let onSubscriberToken; let subscriberClient; - const arbitrarySubscriberSignature = 'c2lnbmF0dXJl'; // signature + const arbitrarySubscriberSignature = 'c2lnbmF0dXJl'; // signature const arbitrarySubscriberGoodToken = { tokenId: 'tokenId2', host: 'host', @@ -518,17 +518,17 @@ describe('Erizo Controller / Erizo Controller', () => { onSubscriberTokenCallback = sinon.stub(); onSubscriberToken = mocks.socketInstance.on.withArgs('token').args[1][1]; onSubscriberToken({ token: arbitrarySubscriberGoodToken }, - onSubscriberTokenCallback); + onSubscriberTokenCallback); callback = amqperMock.callRpc - .withArgs('nuve', 'deleteToken', arbitrarySubscriberGoodToken.tokenId) - .args[0][3].callback; + .withArgs('nuve', 'deleteToken', arbitrarySubscriberGoodToken.tokenId) + .args[0][3].callback; setTimeout(() => { callback({ host: 'host', room: 'roomId', userName: 'user2' }); setTimeout(() => { onSubscriberAutoSubscribe = mocks.socketInstance.on - .withArgs('autoSubscribe').args[1][1]; + .withArgs('autoSubscribe').args[1][1]; room.forEachClient((aClient) => { if (aClient.token.userName === 'user2') { subscriberClient = aClient; @@ -734,18 +734,18 @@ describe('Erizo Controller / Erizo Controller', () => { onSubscribe(subscriberOptions, subscriberSdp, subscribeCallback); expect(mocks.socketInstance.emit.withArgs('connection_failed').callCount) - .to.equal(1); + .to.equal(1); }); it('should send signaling event to the socket when receiving bandwidth alerts', - () => { - const signMes = { type: 'bandwidthAlert' }; - mocks.roomControllerInstance.addSubscriber.callsArgWith(3, signMes); + () => { + const signMes = { type: 'bandwidthAlert' }; + mocks.roomControllerInstance.addSubscriber.callsArgWith(3, signMes); - onSubscribe(subscriberOptions, subscriberSdp, subscribeCallback); + onSubscribe(subscriberOptions, subscriberSdp, subscribeCallback); - expect(mocks.socketInstance.emit.withArgs('stream_message_erizo') - .callCount).to.equal(1); - }); + expect(mocks.socketInstance.emit.withArgs('stream_message_erizo') + .callCount).to.equal(1); + }); it('should emit ErizoJS unreachable', () => { @@ -755,7 +755,7 @@ describe('Erizo Controller / Erizo Controller', () => { onSubscribe(subscriberOptions, subscriberSdp, subscribeCallback); expect(subscribeCallback.withArgs(null, null, 'ErizoJS is not reachable').callCount) - .to.equal(1); + .to.equal(1); }); }); @@ -776,7 +776,7 @@ describe('Erizo Controller / Erizo Controller', () => { onSendDataStream(msg); expect(mocks.socketInstance.emit.withArgs('onDataStream', msg).callCount) - .to.equal(1); + .to.equal(1); }); it('should fail if stream does not exist', () => { @@ -785,7 +785,7 @@ describe('Erizo Controller / Erizo Controller', () => { onSendDataStream(msg); expect(mocks.socketInstance.emit.withArgs('onDataStream', msg).callCount) - .to.equal(0); + .to.equal(0); }); }); @@ -819,8 +819,8 @@ describe('Erizo Controller / Erizo Controller', () => { onStreamMessageErizo(arbitraryMessage); expect(mocks.roomControllerInstance.processStreamMessageFromClient - .withArgs(arbitraryMessage.erizoId, client.id, - arbitraryMessage.streamId).callCount).to.equal(1); + .withArgs(arbitraryMessage.erizoId, client.id, + arbitraryMessage.streamId).callCount).to.equal(1); }); }); @@ -842,7 +842,7 @@ describe('Erizo Controller / Erizo Controller', () => { onUpdateStreamAttributes(msg); expect(mocks.socketInstance.emit.withArgs('onUpdateAttributeStream', msg) - .callCount).to.equal(1); + .callCount).to.equal(1); }); it('should fail if stream does not exist', () => { @@ -851,7 +851,7 @@ describe('Erizo Controller / Erizo Controller', () => { onUpdateStreamAttributes(msg); expect(mocks.socketInstance.emit.withArgs('onUpdateAttributeStream', msg) - .callCount).to.equal(0); + .callCount).to.equal(0); }); }); @@ -911,55 +911,55 @@ describe('Erizo Controller / Erizo Controller', () => { }); it('should call removeSubscriber when succeded (audio only streams) ', - () => { - const unsubscribeCallback = sinon.stub(); - const returnFalse = sinon.stub().returns(false); - client.room.streamManager - .getPublishedStreamById(unsubscribeStreamId).hasVideo = returnFalse; - client.room.streamManager - .getPublishedStreamById(unsubscribeStreamId).hasScreen = returnFalse; - - onUnsubscribe(unsubscribeStreamId, unsubscribeCallback); - - expect(mocks.roomControllerInstance.removeSubscriber.callCount).to.equal(1); - mocks.roomControllerInstance.removeSubscriber - .firstCall.callArgWith(2, true); - expect(unsubscribeCallback.withArgs(true).callCount).to.equal(1); - }); + () => { + const unsubscribeCallback = sinon.stub(); + const returnFalse = sinon.stub().returns(false); + client.room.streamManager + .getPublishedStreamById(unsubscribeStreamId).hasVideo = returnFalse; + client.room.streamManager + .getPublishedStreamById(unsubscribeStreamId).hasScreen = returnFalse; + + onUnsubscribe(unsubscribeStreamId, unsubscribeCallback); + + expect(mocks.roomControllerInstance.removeSubscriber.callCount).to.equal(1); + mocks.roomControllerInstance.removeSubscriber + .firstCall.callArgWith(2, true); + expect(unsubscribeCallback.withArgs(true).callCount).to.equal(1); + }); it('should call removeSubscriber when succeded (video only streams) ', - () => { - const unsubscribeCallback = sinon.stub(); - const returnFalse = sinon.stub().returns(false); - client.room.streamManager - .getPublishedStreamById(unsubscribeStreamId).hasAudio = returnFalse; - client.room.streamManager - .getPublishedStreamById(unsubscribeStreamId).hasScreen = returnFalse; - - onUnsubscribe(unsubscribeStreamId, unsubscribeCallback); - - expect(mocks.roomControllerInstance.removeSubscriber.callCount).to.equal(1); - mocks.roomControllerInstance.removeSubscriber - .firstCall.callArgWith(2, true); - expect(unsubscribeCallback.withArgs(true).callCount).to.equal(1); - }); + () => { + const unsubscribeCallback = sinon.stub(); + const returnFalse = sinon.stub().returns(false); + client.room.streamManager + .getPublishedStreamById(unsubscribeStreamId).hasAudio = returnFalse; + client.room.streamManager + .getPublishedStreamById(unsubscribeStreamId).hasScreen = returnFalse; + + onUnsubscribe(unsubscribeStreamId, unsubscribeCallback); + + expect(mocks.roomControllerInstance.removeSubscriber.callCount).to.equal(1); + mocks.roomControllerInstance.removeSubscriber + .firstCall.callArgWith(2, true); + expect(unsubscribeCallback.withArgs(true).callCount).to.equal(1); + }); it('should call removeSubscriber when succeded (screen only streams) ', - () => { - const unsubscribeCallback = sinon.stub(); - const returnFalse = sinon.stub().returns(false); - client.room.streamManager - .getPublishedStreamById(unsubscribeStreamId).hasAudio = returnFalse; - client.room.streamManager - .getPublishedStreamById(unsubscribeStreamId).hasVideo = returnFalse; - - onUnsubscribe(unsubscribeStreamId, unsubscribeCallback); - - expect(mocks.roomControllerInstance.removeSubscriber.callCount).to.equal(1); - mocks.roomControllerInstance.removeSubscriber - .firstCall.callArgWith(2, true); - expect(unsubscribeCallback.withArgs(true).callCount).to.equal(1); - }); + () => { + const unsubscribeCallback = sinon.stub(); + const returnFalse = sinon.stub().returns(false); + client.room.streamManager + .getPublishedStreamById(unsubscribeStreamId).hasAudio = returnFalse; + client.room.streamManager + .getPublishedStreamById(unsubscribeStreamId).hasVideo = returnFalse; + + onUnsubscribe(unsubscribeStreamId, unsubscribeCallback); + + expect(mocks.roomControllerInstance.removeSubscriber.callCount).to.equal(1); + mocks.roomControllerInstance.removeSubscriber + .firstCall.callArgWith(2, true); + expect(unsubscribeCallback.withArgs(true).callCount).to.equal(1); + }); it('should not call removePublisher in p2p rooms', () => { const unsubscribeCallback = sinon.stub(); @@ -1023,77 +1023,77 @@ describe('Erizo Controller / Erizo Controller', () => { onUnpublish(streamId, unpublishCallback); expect(mocks.roomControllerInstance.removePublisher - .withArgs(client.id, streamId) - .callCount).to.equal(1); + .withArgs(client.id, streamId) + .callCount).to.equal(1); mocks.roomControllerInstance.removePublisher .withArgs(client.id, streamId).callArgWith(2, true); expect(mocks.socketInstance.emit.withArgs('onRemoveStream').callCount) - .to.equal(1); + .to.equal(1); expect(unpublishCallback.withArgs(true).callCount).to.equal(1); }); it('should send a onRemoveStream event when succeded (audio only streams) ', - () => { - const unpublishCallback = sinon.stub(); - const returnFalse = sinon.stub().returns(false); - client.room.streamManager - .getPublishedStreamById(streamId).hasVideo = returnFalse; - client.room.streamManager - .getPublishedStreamById(streamId).hasScreen = returnFalse; - - onUnpublish(streamId, unpublishCallback); - - expect(mocks.roomControllerInstance - .removePublisher.withArgs(client.id, streamId) - .callCount).to.equal(1); - mocks.roomControllerInstance.removePublisher - .withArgs(client.id, streamId).callArgWith(2, true); - expect(mocks.socketInstance.emit.withArgs('onRemoveStream').callCount) - .to.equal(1); - expect(unpublishCallback.withArgs(true).callCount).to.equal(1); - }); + () => { + const unpublishCallback = sinon.stub(); + const returnFalse = sinon.stub().returns(false); + client.room.streamManager + .getPublishedStreamById(streamId).hasVideo = returnFalse; + client.room.streamManager + .getPublishedStreamById(streamId).hasScreen = returnFalse; + + onUnpublish(streamId, unpublishCallback); + + expect(mocks.roomControllerInstance + .removePublisher.withArgs(client.id, streamId) + .callCount).to.equal(1); + mocks.roomControllerInstance.removePublisher + .withArgs(client.id, streamId).callArgWith(2, true); + expect(mocks.socketInstance.emit.withArgs('onRemoveStream').callCount) + .to.equal(1); + expect(unpublishCallback.withArgs(true).callCount).to.equal(1); + }); it('should send a onRemoveStream event when succeded (video only streams) ', - () => { - const unpublishCallback = sinon.stub(); - const returnFalse = sinon.stub().returns(false); - client.room.streamManager - .getPublishedStreamById(streamId).hasAudio = returnFalse; - client.room.streamManager - .getPublishedStreamById(streamId).hasScreen = returnFalse; - - onUnpublish(streamId, unpublishCallback); - - expect(mocks.roomControllerInstance.removePublisher - .withArgs(client.id, streamId) - .callCount).to.equal(1); - mocks.roomControllerInstance.removePublisher - .withArgs(client.id, streamId).callArgWith(2, true); - expect(mocks.socketInstance.emit.withArgs('onRemoveStream').callCount) - .to.equal(1); - expect(unpublishCallback.withArgs(true).callCount).to.equal(1); - }); + () => { + const unpublishCallback = sinon.stub(); + const returnFalse = sinon.stub().returns(false); + client.room.streamManager + .getPublishedStreamById(streamId).hasAudio = returnFalse; + client.room.streamManager + .getPublishedStreamById(streamId).hasScreen = returnFalse; + + onUnpublish(streamId, unpublishCallback); + + expect(mocks.roomControllerInstance.removePublisher + .withArgs(client.id, streamId) + .callCount).to.equal(1); + mocks.roomControllerInstance.removePublisher + .withArgs(client.id, streamId).callArgWith(2, true); + expect(mocks.socketInstance.emit.withArgs('onRemoveStream').callCount) + .to.equal(1); + expect(unpublishCallback.withArgs(true).callCount).to.equal(1); + }); it('should send a onRemoveStream event when succeded (screen only streams) ', - () => { - const unpublishCallback = sinon.stub(); - const returnFalse = sinon.stub().returns(false); - client.room.streamManager - .getPublishedStreamById(streamId).hasAudio = returnFalse; - client.room.streamManager - .getPublishedStreamById(streamId).hasVideo = returnFalse; - - onUnpublish(streamId, unpublishCallback); - - expect(mocks.roomControllerInstance.removePublisher - .withArgs(client.id, streamId) - .callCount).to.equal(1); - mocks.roomControllerInstance.removePublisher - .withArgs(client.id, streamId).callArgWith(2, true); - expect(mocks.socketInstance.emit.withArgs('onRemoveStream').callCount) - .to.equal(1); - expect(unpublishCallback.withArgs(true).callCount).to.equal(1); - }); + () => { + const unpublishCallback = sinon.stub(); + const returnFalse = sinon.stub().returns(false); + client.room.streamManager + .getPublishedStreamById(streamId).hasAudio = returnFalse; + client.room.streamManager + .getPublishedStreamById(streamId).hasVideo = returnFalse; + + onUnpublish(streamId, unpublishCallback); + + expect(mocks.roomControllerInstance.removePublisher + .withArgs(client.id, streamId) + .callCount).to.equal(1); + mocks.roomControllerInstance.removePublisher + .withArgs(client.id, streamId).callArgWith(2, true); + expect(mocks.socketInstance.emit.withArgs('onRemoveStream').callCount) + .to.equal(1); + expect(unpublishCallback.withArgs(true).callCount).to.equal(1); + }); it('should not call removePublisher in p2p rooms', () => { const unpublishCallback = sinon.stub(); @@ -1103,9 +1103,9 @@ describe('Erizo Controller / Erizo Controller', () => { onUnpublish(streamId, unpublishCallback); expect(mocks.roomControllerInstance.removePublisher - .withArgs(streamId).callCount).to.equal(0); + .withArgs(streamId).callCount).to.equal(0); expect(mocks.socketInstance.emit.withArgs('onRemoveStream').callCount) - .to.equal(1); + .to.equal(1); expect(unpublishCallback.withArgs(true).callCount).to.equal(1); }); }); @@ -1118,7 +1118,7 @@ describe('Erizo Controller / Erizo Controller', () => { onDisconnect(); expect(mocks.socketInstance.emit.withArgs('onRemoveStream').callCount) - .to.equal(1); + .to.equal(1); }); it('should call removePublisher', () => { diff --git a/erizo_controller/test/erizoController/roomController.js b/erizo_controller/test/erizoController/roomController.js index 86eeea860f..493b201e8c 100644 --- a/erizo_controller/test/erizoController/roomController.js +++ b/erizo_controller/test/erizoController/roomController.js @@ -1,6 +1,6 @@ /* global require, describe, it, beforeEach, afterEach */ - /* eslint-disable no-unused-expressions */ +/* eslint-disable no-unused-expressions */ const mocks = require('../utils'); // eslint-disable-next-line import/no-extraneous-dependencies @@ -209,9 +209,9 @@ describe('Erizo Controller / Room Controller', () => { expect(amqperMock.callRpc.args[0][1]).to.equal('addPublisher'); amqperMock.callRpc.args[0][3].callback('timeout'); - amqperMock.callRpc.args[1][3].callback('timeout'); // First retry - amqperMock.callRpc.args[2][3].callback('timeout'); // Second retry - amqperMock.callRpc.args[3][3].callback('timeout'); // Third retry + amqperMock.callRpc.args[1][3].callback('timeout'); // First retry + amqperMock.callRpc.args[2][3].callback('timeout'); // Second retry + amqperMock.callRpc.args[3][3].callback('timeout'); // Third retry expect(callback.callCount).to.equal(4); expect(callback.args[0][0]).to.equal('timeout-erizojs-retry'); @@ -224,9 +224,9 @@ describe('Erizo Controller / Room Controller', () => { controller.addPublisher(kArbitraryClientId, kArbitraryStreamId, kArbitraryOptions, callback); amqperMock.callRpc.args[0][3].callback('timeout'); - amqperMock.callRpc.args[1][3].callback('timeout'); // First retry - amqperMock.callRpc.args[2][3].callback('timeout'); // Second retry - amqperMock.callRpc.args[3][3].callback('timeout'); // Third retry + amqperMock.callRpc.args[1][3].callback('timeout'); // First retry + amqperMock.callRpc.args[2][3].callback('timeout'); // Second retry + amqperMock.callRpc.args[3][3].callback('timeout'); // Third retry controller.removePublisher(kArbitraryClientId, kArbitraryStreamId); @@ -301,9 +301,9 @@ describe('Erizo Controller / Room Controller', () => { expect(amqperMock.callRpc.args[0][1]).to.equal('addSubscriber'); amqperMock.callRpc.args[0][3].callback('timeout'); - amqperMock.callRpc.args[1][3].callback('timeout'); // First retry - amqperMock.callRpc.args[2][3].callback('timeout'); // Second retry - amqperMock.callRpc.args[3][3].callback('timeout'); // Third retry + amqperMock.callRpc.args[1][3].callback('timeout'); // First retry + amqperMock.callRpc.args[2][3].callback('timeout'); // Second retry + amqperMock.callRpc.args[3][3].callback('timeout'); // Third retry expect(callback.callCount).to.equal(1); expect(callback.args[0][0]).to.equal('timeout'); @@ -396,7 +396,7 @@ describe('Erizo Controller / Room Controller', () => { describe('And Remove', () => { beforeEach(() => { controller.addMultipleSubscribers(kArbitraryClientId, [kArbitraryStreamId], - kArbitraryOptions, sinon.stub()); + kArbitraryOptions, sinon.stub()); amqperMock.callRpc.args[0][3].callback({ type: 'multiple-initializing', streamIds: [kArbitraryStreamId] }); }); diff --git a/erizo_controller/test/erizoJS/erizoJSController.js b/erizo_controller/test/erizoJS/erizoJSController.js index da9250288e..516aaa421f 100644 --- a/erizo_controller/test/erizoJS/erizoJSController.js +++ b/erizo_controller/test/erizoJS/erizoJSController.js @@ -1,6 +1,6 @@ /* global require, describe, it, beforeEach, afterEach */ - /* eslint-disable no-unused-expressions */ +/* eslint-disable no-unused-expressions */ // eslint-disable-next-line no-unused-expressions const mocks = require('../utils'); @@ -14,7 +14,7 @@ describe('Erizo JS Controller', () => { let licodeConfigMock; let erizoApiMock; let controller; - const kActiveUptimeLimit = 1; // in days + const kActiveUptimeLimit = 1; // in days const kMaxTimeSinceLastOperation = 1; // in hours const kCheckUptimeInterval = 1; // in seconds const kArbitraryErizoJSId = 'erizoJSId1'; @@ -137,7 +137,7 @@ describe('Erizo JS Controller', () => { expect(mocks.ExternalInput.setAudioReceiver.args[0][0]).to.equal(mocks.OneToManyProcessor); expect(mocks.ExternalInput.setVideoReceiver.args[0][0]).to.equal(mocks.OneToManyProcessor); expect(mocks.OneToManyProcessor.setExternalPublisher.args[0][0]).to - .equal(mocks.ExternalInput); + .equal(mocks.ExternalInput); expect(callback.callCount).to.equal(1); expect(callback.args[0]).to.deep.equal(['callback', 'success']); }); @@ -183,7 +183,7 @@ describe('Erizo JS Controller', () => { expect(erizoApiMock.ExternalOutput.callCount).to.equal(1); expect(mocks.ExternalOutput.id).to.equal(`${kArbitraryEoUrl}_${kArbitraryEiId}`); expect(mocks.OneToManyProcessor.addExternalOutput.args[0]).to.deep - .equal([mocks.ExternalOutput, kArbitraryEoUrl]); + .equal([mocks.ExternalOutput, kArbitraryEoUrl]); }); it('should fail if Publisher does not exist', () => { @@ -200,14 +200,14 @@ describe('Erizo JS Controller', () => { it('should succeed removing ExternalOutput', () => { controller.removeExternalOutput(kArbitraryEiId, kArbitraryEoUrl); expect(mocks.OneToManyProcessor.removeSubscriber.args[0][0]).to - .equal(kArbitraryEoUrl); + .equal(kArbitraryEoUrl); }); it('should fail if Publisher does not exist', () => { controller.removeExternalOutput(`${kArbitraryEiId}a`, kArbitraryEiUrl); expect(mocks.OneToManyProcessor.removeSubscriber.callCount).to - .equal(0); + .equal(0); }); }); }); @@ -238,7 +238,7 @@ describe('Erizo JS Controller', () => { expect(mocks.MediaStream.setAudioReceiver.args[0][0]).to.equal(mocks.OneToManyProcessor); expect(mocks.MediaStream.setVideoReceiver.args[0][0]).to.equal(mocks.OneToManyProcessor); expect(mocks.OneToManyProcessor.setPublisher.args[0][0]).to - .equal(mocks.MediaStream); + .equal(mocks.MediaStream); expect(callback.callCount).to.equal(1); expect(callback.args[0]).to.deep.equal(['callback', { type: 'initializing', connectionId: `${kArbitraryClientId}_${kArbitraryErizoJSId}_1` }]); @@ -263,12 +263,12 @@ describe('Erizo JS Controller', () => { const secondCallback = sinon.stub(); const subCallback = sinon.stub(); controller.addPublisher(kArbitraryErizoControllerId, kArbitraryClientId, - kArbitraryStreamId, {}, callback); + kArbitraryStreamId, {}, callback); controller.addSubscriber(kArbitraryErizoControllerId, kArbitrarySubClientId, - kArbitraryClientId, {}, subCallback); + kArbitraryClientId, {}, subCallback); controller.addPublisher(kArbitraryErizoControllerId, kArbitraryClientId, - kArbitraryStreamId, {}, secondCallback); + kArbitraryStreamId, {}, secondCallback); setTimeout(() => { expect(callback.callCount).to.equal(1); expect(secondCallback.callCount).to.equal(0); @@ -277,7 +277,7 @@ describe('Erizo JS Controller', () => { }); it('should succeed sending offer event', (done) => { - mocks.WebRtcConnection.init.returns(1).callsArgWith(0, 103, ''); // CONN_GATHERED + mocks.WebRtcConnection.init.returns(1).callsArgWith(0, 103, ''); // CONN_GATHERED controller.addPublisher(kArbitraryErizoControllerId, kArbitraryClientId, kArbitraryStreamId, { createOffer: { audio: true, video: true, bundle: true } }, callback); setTimeout(() => { @@ -310,9 +310,9 @@ describe('Erizo JS Controller', () => { }); it('should succeed sending answer event', (done) => { - mocks.WebRtcConnection.init.returns(1).callsArgWith(0, 103, ''); // CONN_GATHERED + mocks.WebRtcConnection.init.returns(1).callsArgWith(0, 103, ''); // CONN_GATHERED controller.addPublisher(kArbitraryErizoControllerId, kArbitraryClientId, - kArbitraryStreamId, {}, callback); + kArbitraryStreamId, {}, callback); controller.processConnectionMessage(kArbitraryErizoControllerId, kArbitraryClientId, `${kArbitraryClientId}_${kArbitraryErizoJSId}_1`, { type: 'offer', sdp: '' }); setTimeout(() => { @@ -330,7 +330,7 @@ describe('Erizo JS Controller', () => { it('should succeed sending answer event from SDP in Tricke ICE', (done) => { controller.addPublisher(kArbitraryErizoControllerId, kArbitraryClientId, - kArbitraryStreamId, { trickleIce: true }, callback); + kArbitraryStreamId, { trickleIce: true }, callback); controller.processConnectionMessage(kArbitraryErizoControllerId, kArbitraryClientId, `${kArbitraryClientId}_${kArbitraryErizoJSId}_1`, { type: 'offer', sdp: '' }); setTimeout(() => { @@ -347,9 +347,9 @@ describe('Erizo JS Controller', () => { }); it('should succeed sending candidate event', (done) => { - mocks.WebRtcConnection.init.returns(1).callsArgWith(0, 201, ''); // CONN_CANDIDATE + mocks.WebRtcConnection.init.returns(1).callsArgWith(0, 201, ''); // CONN_CANDIDATE controller.addPublisher(kArbitraryErizoControllerId, kArbitraryClientId, - kArbitraryStreamId, {}, callback); + kArbitraryStreamId, {}, callback); setTimeout(() => { expect(callback.callCount).to.equal(1); expect(callback.args[0]).to.deep.equal(['callback', @@ -364,9 +364,9 @@ describe('Erizo JS Controller', () => { }); it('should succeed sending failed event', (done) => { - mocks.WebRtcConnection.init.returns(1).callsArgWith(0, 500, ''); // CONN_FAILED + mocks.WebRtcConnection.init.returns(1).callsArgWith(0, 500, ''); // CONN_FAILED controller.addPublisher(kArbitraryErizoControllerId, kArbitraryClientId, - kArbitraryStreamId, {}, callback); + kArbitraryStreamId, {}, callback); setTimeout(() => { expect(callback.callCount).to.equal(1); expect(callback.args[0]).to.deep.equal(['callback', @@ -390,26 +390,26 @@ describe('Erizo JS Controller', () => { return Promise.resolve().then(() => { initCallback = stub.getCall(0).args[0]; - initCallback(103, ''); // CONN_GATHERED - initCallback(104, ''); // CONN_READY + initCallback(103, ''); // CONN_GATHERED + initCallback(104, ''); // CONN_READY }).then(() => controller.processConnectionMessage(kArbitraryErizoControllerId, kArbitraryClientId, `${kArbitraryClientId}_${kArbitraryErizoJSId}_1`, { type: 'offer', sdp: '' })) - .then(() => { - expect(callback.callCount).to.equal(2); - expect(callback.args[0]).to.deep.equal(['callback', - { type: 'initializing', connectionId: `${kArbitraryClientId}_${kArbitraryErizoJSId}_1` }]); - expect(amqperMock.callRpc.withArgs(`erizoController_${kArbitraryErizoControllerId}`, - 'connectionStatusEvent').callCount).to.equal(2); - const call = amqperMock.callRpc.withArgs(`erizoController_${kArbitraryErizoControllerId}`, - 'connectionStatusEvent'); - expect(call.args[0][2][3].type).to.equal('ready'); - expect(call.args[1][2][3].type).to.equal('answer'); - }); + .then(() => { + expect(callback.callCount).to.equal(2); + expect(callback.args[0]).to.deep.equal(['callback', + { type: 'initializing', connectionId: `${kArbitraryClientId}_${kArbitraryErizoJSId}_1` }]); + expect(amqperMock.callRpc.withArgs(`erizoController_${kArbitraryErizoControllerId}`, + 'connectionStatusEvent').callCount).to.equal(2); + const call = amqperMock.callRpc.withArgs(`erizoController_${kArbitraryErizoControllerId}`, + 'connectionStatusEvent'); + expect(call.args[0][2][3].type).to.equal('ready'); + expect(call.args[1][2][3].type).to.equal('answer'); + }); }); it('should succeed sending started event', () => { - mocks.WebRtcConnection.init.returns(1).callsArgWith(0, 101); // CONN_INITIAL + mocks.WebRtcConnection.init.returns(1).callsArgWith(0, 101); // CONN_INITIAL mocks.WebRtcConnection.addMediaStream.returns(Promise.resolve()); controller.addPublisher(kArbitraryErizoControllerId, kArbitraryClientId, kArbitraryStreamId, {}, callback); @@ -434,7 +434,7 @@ describe('Erizo JS Controller', () => { it('should set remote sdp when received', () => { controller.processConnectionMessage(kArbitraryErizoControllerId, kArbitraryClientId, `${kArbitraryClientId}_${kArbitraryErizoJSId}_1`, - { type: 'offer', sdp: '', config: {} }); + { type: 'offer', sdp: '', config: {} }); expect(mocks.WebRtcConnection.setRemoteDescription.callCount).to.equal(1); }); @@ -501,9 +501,9 @@ describe('Erizo JS Controller', () => { let initCallback; return Promise.resolve().then(() => { initCallback = mocks.WebRtcConnection.init.getCall(1).args[0]; - initCallback(103, ''); // CONN_GATHERED + initCallback(103, ''); // CONN_GATHERED }).then(() => { - initCallback(104, ''); // CONN_READY + initCallback(104, ''); // CONN_READY }).then(() => { expect(subCallback.callCount).to.equal(2); expect(subCallback.args[0]).to.deep.equal(['callback', { type: 'ready' }]); diff --git a/erizo_controller/test/utils.js b/erizo_controller/test/utils.js index ac01709123..c7d60eae4e 100644 --- a/erizo_controller/test/utils.js +++ b/erizo_controller/test/utils.js @@ -105,8 +105,8 @@ module.exports.reset = () => { set: sinon.stub(), sockets: { on: sinon.stub(), - socket: sinon.stub().returns(module.exports.socketInstance), // v0.9 - sockets: { streamId1: module.exports.socketInstance, // v2.0.3 + socket: sinon.stub().returns(module.exports.socketInstance), // v0.9 + sockets: { streamId1: module.exports.socketInstance, // v2.0.3 undefined: module.exports.socketInstance }, indexOf: sinon.stub(), }, @@ -162,7 +162,7 @@ module.exports.reset = () => { setRemoteSdp: sinon.stub(), setRemoteDescription: sinon.stub(), getLocalDescription: sinon.stub() - .returns(Promise.resolve(module.exports.ConnectionDescription)), + .returns(Promise.resolve(module.exports.ConnectionDescription)), addRemoteCandidate: sinon.stub(), addMediaStream: sinon.stub().returns(Promise.resolve()), removeMediaStream: sinon.stub(), diff --git a/extras/basic_example/public/quality_layers.js b/extras/basic_example/public/quality_layers.js index 398e69bc46..3edd2cb833 100644 --- a/extras/basic_example/public/quality_layers.js +++ b/extras/basic_example/public/quality_layers.js @@ -226,13 +226,13 @@ const updateCharts = (stream) => { for (const temporalLayer in qualityLayersData[spatialLayer]) { const key = `Spatial ${spatialLayer} / Temporal ${temporalLayer}`; updateSeriesForKey(stream, subId, key, spatialLayer, temporalLayer, - date, qualityLayersData[spatialLayer][temporalLayer], undefined, - maxActiveSpatialLayer >= spatialLayer); + date, qualityLayersData[spatialLayer][temporalLayer], undefined, + maxActiveSpatialLayer >= spatialLayer); } } if (qualityLayersData.selectedSpatialLayer !== undefined) { selectedLayers += `Spatial: ${qualityLayersData.selectedSpatialLayer - } / Temporal: ${qualityLayersData.selectedTemporalLayer}`; + } / Temporal: ${qualityLayersData.selectedTemporalLayer}`; } } if (!data[i].total) { @@ -247,19 +247,19 @@ const updateCharts = (stream) => { const rtxBitrate = data[i].total.rtxBitrate || 0; updateSeriesForKey(stream, subId, 'Current Received', undefined, undefined, - date, totalBitrate, selectedLayers); + date, totalBitrate, selectedLayers); updateSeriesForKey(stream, subId, 'Estimated Bandwidth', undefined, undefined, - date, bitrateEstimated); + date, bitrateEstimated); updateSeriesForKey(stream, subId, 'REMB Bandwidth', undefined, undefined, - date, remb); + date, remb); updateSeriesForKey(stream, subId, 'Target Video Bitrate', undefined, undefined, - date, targetVideoBitrate); + date, targetVideoBitrate); updateSeriesForKey(stream, subId, 'Number Of Streams', undefined, undefined, - date, numberOfStreams); + date, numberOfStreams); updateSeriesForKey(stream, subId, 'Padding Bitrate', undefined, undefined, - date, paddingBitrate); + date, paddingBitrate); updateSeriesForKey(stream, subId, 'Rtx Bitrate', undefined, undefined, - date, rtxBitrate); + date, rtxBitrate); } } }); diff --git a/nuve/nuveAPI/auth/nuveAuthenticator.js b/nuve/nuveAPI/auth/nuveAuthenticator.js index 73f46a63fc..3603edc6b6 100644 --- a/nuve/nuveAPI/auth/nuveAuthenticator.js +++ b/nuve/nuveAPI/auth/nuveAuthenticator.js @@ -25,7 +25,7 @@ const checkTimestamp = (ser, params) => { if (newTS < lastTS || (lastTS === newTS && lastC === newC)) { log.debug(`message: checkTimestamp lastTimestamp: ${lastTS}, newTimestamp: ${newTS - }, lastCnonce: ${lastC}, newCnonce: ${newC}`); + }, lastCnonce: ${lastC}, newCnonce: ${newC}`); return false; } @@ -58,25 +58,25 @@ exports.authenticate = (req, res, next) => { if (authHeader !== undefined) { params = mauthParser.parseHeader(authHeader); - // Get the service from the data base. + // Get the service from the data base. serviceRegistry.getService(params.serviceid, (serv) => { if (serv === undefined || serv === null) { log.info(`message: authenticate fail - unknown service, serviceId: ${ - params.serviceid}`); + params.serviceid}`); res.status(401).send({ 'WWW-Authenticate': challengeReq }); return; } const key = serv.key; - // Check if timestam and cnonce are valids in order to avoid duplicate requests. + // Check if timestam and cnonce are valids in order to avoid duplicate requests. if (!checkTimestamp(serv, params)) { log.info('message: authenticate fail - Invalid timestamp or cnonce'); res.status(401).send({ 'WWW-Authenticate': challengeReq }); return; } - // Check if the signature is valid. + // Check if the signature is valid. if (checkSignature(params, key)) { if (params.username !== undefined && params.role !== undefined) { req.user = params.username; @@ -86,7 +86,7 @@ exports.authenticate = (req, res, next) => { cache[serv.name] = params; req.service = serv; - // If everything in the authentication is valid continue with the request. + // If everything in the authentication is valid continue with the request. next(); } else { log.info('message: authenticate fail - wrong credentials'); diff --git a/nuve/nuveAPI/cloudHandler.js b/nuve/nuveAPI/cloudHandler.js index ae3f6347b9..6c09792e4b 100644 --- a/nuve/nuveAPI/cloudHandler.js +++ b/nuve/nuveAPI/cloudHandler.js @@ -22,12 +22,12 @@ const MAX_KA_COUNT = 10; let getErizoController; const getEcQueue = (callback) => { - //* ****************************************************************** - // States: - // 0: Not available - // 1: Warning - // 2: Available - //* ****************************************************************** + //* ****************************************************************** + // States: + // 0: Not available + // 1: Warning + // 2: Available + //* ****************************************************************** erizoControllerRegistry.getErizoControllers((erizoControllers) => { let ecQueue = []; @@ -157,7 +157,7 @@ exports.keepAlive = (id, callback) => { if (erizoController) { erizoControllerRegistry.updateErizoController(id, { keepAlive: 0 }); result = 'ok'; - // log.info('KA: ', id); + // log.info('KA: ', id); } else { result = 'whoareyou'; log.warn('I received a keepAlive message from an unknown erizoController'); @@ -256,8 +256,8 @@ exports.deleteUser = (user, roomId, callback) => { if (room && room.erizoControllerId) { const rpcID = `erizoController_${room.erizoControllerId}`; rpc.callRpc(rpcID, - 'deleteUser', - [{ user, roomId }], + 'deleteUser', + [{ user, roomId }], { callback(result) { callback(result); } }); diff --git a/nuve/nuveAPI/logger.js b/nuve/nuveAPI/logger.js index 12e3427b02..944d2f43f3 100644 --- a/nuve/nuveAPI/logger.js +++ b/nuve/nuveAPI/logger.js @@ -31,7 +31,7 @@ exports.logger.objectToLog = (jsonInput) => { } const jsonString = JSON.stringify(jsonInput, logJsonReplacer); return jsonString.replace(/['"]+/g, '') - .replace(/[:]+/g, ': ') - .replace(/[,]+/g, ', ') - .slice(1, -1); + .replace(/[:]+/g, ': ') + .replace(/[,]+/g, ', ') + .slice(1, -1); }; diff --git a/nuve/nuveAPI/mdb/erizoControllerRegistry.js b/nuve/nuveAPI/mdb/erizoControllerRegistry.js index 3360973b86..4cc856e22b 100644 --- a/nuve/nuveAPI/mdb/erizoControllerRegistry.js +++ b/nuve/nuveAPI/mdb/erizoControllerRegistry.js @@ -76,7 +76,7 @@ exports.removeErizoController = (id) => { if (hasEC) { db.erizoControllers.remove({ _id: db.ObjectId(id) }, (error) => { if (error) { - log.warn('message: removeErizoController error, ' + + log.warn('message: removeErizoController error, ', `${logger.objectToLog(error)}`); } }); diff --git a/nuve/nuveAPI/resource/roomResource.js b/nuve/nuveAPI/resource/roomResource.js index e52e0a0c39..3590bb3654 100644 --- a/nuve/nuveAPI/resource/roomResource.js +++ b/nuve/nuveAPI/resource/roomResource.js @@ -31,7 +31,7 @@ exports.represent = (req, res) => { res.status(404).send('Room does not exist'); } else { log.info(`message: representRoom success, roomId: ${currentRoom._id - }, serviceId: ${req.service._id}`); + }, serviceId: ${req.service._id}`); res.send(currentRoom); } }); diff --git a/nuve/nuveAPI/resource/tokensResource.js b/nuve/nuveAPI/resource/tokensResource.js index 50510c4a2f..b14eb0fc46 100644 --- a/nuve/nuveAPI/resource/tokensResource.js +++ b/nuve/nuveAPI/resource/tokensResource.js @@ -69,7 +69,7 @@ const generateToken = (req, callback) => { token.mediaConfiguration = currentRoom.mediaConfiguration; } - // Values to be filled from the erizoController + // Values to be filled from the erizoController token.secure = false; if (currentRoom.p2p) { @@ -104,7 +104,7 @@ const generateToken = (req, callback) => { } else { token = currentService.testToken; - log.info('message: generateTestToken already generated - returning, ' + + log.info('message: generateTestToken already generated - returning, ', `${logger.objectToLog(token)}`); tokenS = getTokenString(token._id, token); diff --git a/nuve/nuveAPI/resource/userResource.js b/nuve/nuveAPI/resource/userResource.js index 9dbf108881..d6adf016c6 100644 --- a/nuve/nuveAPI/resource/userResource.js +++ b/nuve/nuveAPI/resource/userResource.js @@ -82,6 +82,6 @@ exports.deleteUser = (req, res) => { res.send(result); } }); - // Consultar RabbitMQ + // Consultar RabbitMQ }); }; diff --git a/nuve/nuveAPI/rpc/rpc.js b/nuve/nuveAPI/rpc/rpc.js index fe2a6c12ff..8743141fc9 100644 --- a/nuve/nuveAPI/rpc/rpc.js +++ b/nuve/nuveAPI/rpc/rpc.js @@ -18,7 +18,7 @@ config.rabbit.port = config.rabbit.port || 5672; const TIMEOUT = 3000; let corrID = 0; -const map = {}; // {corrID: {fn: callback, to: timeout}} +const map = {}; // {corrID: {fn: callback, to: timeout}} let clientQueue; let connection; let exc; @@ -43,12 +43,12 @@ exports.connect = (callback) => { connection.on('ready', () => { log.info('message: AMQP connected'); - // Create a direct exchange + // Create a direct exchange exc = connection.exchange('rpcExchange', { type: 'direct' }, (exchange) => { log.info(`message: rpcExchange open, exchangeName: ${exchange.name}`); const next = () => { - // Create the queue for receive messages + // Create the queue for receive messages const q = connection.queue('nuveQueue', (queue) => { log.info(`message: queue open, queueName: ${queue.name}`); @@ -56,7 +56,7 @@ exports.connect = (callback) => { q.subscribe((message) => { rpcPublic[message.method](message.args, (type, result) => { exc.publish(message.replyTo, - { data: result, corrID: message.corrID, type }); + { data: result, corrID: message.corrID, type }); }); }); if (callback) { @@ -65,7 +65,7 @@ exports.connect = (callback) => { }); }; - // Create the queue for send messages + // Create the queue for send messages clientQueue = connection.queue('', (q) => { log.info(`message: clientQueue open, queueName: ${q.name}`); diff --git a/nuve/nuveAPI/rpc/rpcPublic.js b/nuve/nuveAPI/rpc/rpcPublic.js index 6aa118cb71..754cc418f6 100644 --- a/nuve/nuveAPI/rpc/rpcPublic.js +++ b/nuve/nuveAPI/rpc/rpcPublic.js @@ -22,7 +22,7 @@ exports.deleteToken = (id, callback) => { callback('callback', 'error'); } else if (token.use !== undefined) { let s; - // Is a test token + // Is a test token if (token.use > 490) { s = token.service; serviceRegistry.getService(s, (service) => { diff --git a/nuve/nuveAPI/test/auth/mauthParser.js b/nuve/nuveAPI/test/auth/mauthParser.js index 36bf685175..86d4512048 100644 --- a/nuve/nuveAPI/test/auth/mauthParser.js +++ b/nuve/nuveAPI/test/auth/mauthParser.js @@ -17,9 +17,9 @@ describe('MAuth Parser', () => { username: 'arbitraryUser' } }, { header: 'MAuth realm="arbitraryRealm",mauth_username=arbitraryUser,' + 'mauth_field=arbitraryField', - json: { realm: '"arbitraryRealm"', - username: 'arbitraryUser', - field: 'arbitraryField' } }, + json: { realm: '"arbitraryRealm"', + username: 'arbitraryUser', + field: 'arbitraryField' } }, ]; describe('parseHeader', () => { @@ -106,7 +106,7 @@ describe('MAuth Parser', () => { }]; serverSignatureParams.forEach((param) => { it(`should create a valid signature from timestamp ${ - JSON.stringify(param.timestamp)}`, () => { + JSON.stringify(param.timestamp)}`, () => { const signature = mauthParser.calculateServerSignature(param, param.key); expect(signature).to.deep.equal(param.signature); }); diff --git a/nuve/nuveAPI/test/auth/nuveAuthenticator.js b/nuve/nuveAPI/test/auth/nuveAuthenticator.js index 25db1d5aaf..befdabca88 100644 --- a/nuve/nuveAPI/test/auth/nuveAuthenticator.js +++ b/nuve/nuveAPI/test/auth/nuveAuthenticator.js @@ -26,7 +26,7 @@ describe('Nuve Authenticator', () => { // mauthParserMock = mocks.start(mocks.mauthParser); serviceRegistryMock = mocks.start(mocks.serviceRegistry); -// eslint-disable-next-line global-require + // eslint-disable-next-line global-require nuveAuthenticator = require('../../auth/nuveAuthenticator'); const onRequest = (req, res) => { @@ -84,7 +84,7 @@ describe('Nuve Authenticator', () => { request(app) .get('/arbitraryFunction') .set('Authorization', - 'MAuth realm="",mauth_serviceid=1,' + + 'MAuth realm="",mauth_serviceid=1,' + 'mauth_timestamp=1,mauth_signature_method=HMAC_SHA1,' + 'mauth_signature=MzgwOTY5YWY2ZGNkYWM1YTMwM2M0MGM3ZTZmODhkYmEyOTEzNmVkZQ==') .expect(401, { 'WWW-Authenticate': 'MAuth realm="http://marte3.dit.upm.es"' }) @@ -98,7 +98,7 @@ describe('Nuve Authenticator', () => { request(app) .get('/arbitraryFunction') .set('Authorization', - 'MAuth realm="",mauth_serviceid=1,' + + 'MAuth realm="",mauth_serviceid=1,' + 'mauth_timestamp=1,mauth_signature_method=HMAC_SHA1,' + 'mauth_signature=YmI1OTZlYWM1YzNjZjZhZTRmMTIyODQ1YTNiNWVhNWM0MzAxMmM5Yw==') .end((err) => { diff --git a/nuve/nuveAPI/test/ch_policies/default_policy.js b/nuve/nuveAPI/test/ch_policies/default_policy.js index c49a140f92..99e638b8f1 100644 --- a/nuve/nuveAPI/test/ch_policies/default_policy.js +++ b/nuve/nuveAPI/test/ch_policies/default_policy.js @@ -11,8 +11,8 @@ const kArbitraryErizoController2 = 'erizoController1'; describe('Default Policy', () => { it('should return the first Erizo Controller in the queue', () => { const result = policy.getErizoController( - {}, // room - [kArbitraryErizoController2, kArbitraryErizoController1]); + {}, // room + [kArbitraryErizoController2, kArbitraryErizoController1]); expect(result).to.deep.equal(kArbitraryErizoController2); }); }); diff --git a/nuve/nuveAPI/test/mdb/erizoControllerRegistry.js b/nuve/nuveAPI/test/mdb/erizoControllerRegistry.js index 27c1dec2cd..9c3b584ccb 100644 --- a/nuve/nuveAPI/test/mdb/erizoControllerRegistry.js +++ b/nuve/nuveAPI/test/mdb/erizoControllerRegistry.js @@ -88,7 +88,7 @@ describe('ErizoController Registry', () => { it('should call update on Database when calling updateEC', () => { erizoControllerRegistry.updateErizoController(kArbitraryErizoControllerId, - kArbitraryErizoController); + kArbitraryErizoController); // eslint-disable-next-line no-unused-expressions expect(dataBase.db.erizoControllers.update.calledOnce).to.be.true; diff --git a/nuve/nuveAPI/test/utils.js b/nuve/nuveAPI/test/utils.js index ed3b680b05..4863c0ffd4 100644 --- a/nuve/nuveAPI/test/utils.js +++ b/nuve/nuveAPI/test/utils.js @@ -27,7 +27,7 @@ module.exports.deleteRequireCache = () => { }); }; -// eslint-disable-next-line +// eslint-disable-next-line const dbEntry = () => { return { find: sinon.stub(), diff --git a/package.json b/package.json index 67da0c2772..2521b5601b 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "async": "^2.1.2", "chai": "^3.5.0", "del": "~3.0.0", - "eslint": "^3.19.0", + "eslint": "^4.19.1", "eslint-config-airbnb": "^15.0.1", "eslint-plugin-import": "^2.6.0", "eslint-plugin-jsx-a11y": "^5.1.0",