提交 19d62979 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

node: cosmetic changes

上级 40fe414a
......@@ -266,33 +266,6 @@ class Consumer extends EnhancedEventEmitter
});
}
/**
* Get the Consumer stats.
*
* @return {Promise}
*/
getStats()
{
logger.debug('getStats()');
if (this._closed)
return Promise.reject(new errors.InvalidStateError('Consumer closed'));
return this._channel.request('consumer.getStats', this._internal)
.then((data) =>
{
logger.debug('"consumer.getStats" request succeeded');
return data;
})
.catch((error) =>
{
logger.error('"consumer.getStats" request failed: %s', String(error));
throw error;
});
}
toJson()
{
const json =
......@@ -434,74 +407,6 @@ class Consumer extends EnhancedEventEmitter
return this.paused;
}
/**
* Enables periodic stats retrieval.
*
*/
enableStats(appData)
{
logger.debug('enableStats()');
const { interval } = appData;
if (this._closed)
{
logger.error('enableStats() | Consumer closed');
return;
}
if (this._statsEnabled)
return;
this._statsEnabled = true;
this._statsInterval = setInterval(() =>
{
if (this.paused || !this.enabled)
return;
this.getStats()
.then((stats) =>
{
const data =
{
id : this.id,
peerName : this.peer.name,
stats
};
this.emit('@notify', 'consumerStats', data);
})
.catch((error) =>
{
logger.error('"getStats" request failed: %s', String(error));
});
}, interval * 1000);
}
/**
* Disables periodic stats retrieval.
*
*/
disableStats()
{
logger.debug('disableStats()');
if (this._closed)
{
logger.error('disableStats() | Consumer closed');
return;
}
if (!this._statsEnabled)
return;
this._statsEnabled = false;
clearInterval(this._statsInterval);
}
/**
* The remote Consumer was paused.
* Invoked via remote notification.
......@@ -765,6 +670,99 @@ class Consumer extends EnhancedEventEmitter
});
}
/**
* Get the Consumer stats.
*
* @return {Promise}
*/
getStats()
{
logger.debug('getStats()');
if (this._closed)
return Promise.reject(new errors.InvalidStateError('Consumer closed'));
return this._channel.request('consumer.getStats', this._internal)
.then((data) =>
{
logger.debug('"consumer.getStats" request succeeded');
return data;
})
.catch((error) =>
{
logger.error('"consumer.getStats" request failed: %s', String(error));
throw error;
});
}
/**
* Enables periodic stats retrieval.
*/
enableStats(options)
{
logger.debug('enableStats()');
const { interval } = options;
if (this._closed)
{
logger.error('enableStats() | Consumer closed');
return;
}
if (this._statsEnabled)
return;
this._statsEnabled = true;
this._statsInterval = setInterval(() =>
{
if (this.paused || !this.enabled)
return;
this.getStats()
.then((stats) =>
{
const data =
{
id : this.id,
peerName : this.peer.name,
stats
};
this.emit('@notify', 'consumerStats', data);
})
.catch((error) =>
{
logger.error('"getStats" request failed: %s', String(error));
});
}, interval * 1000);
}
/**
* Disables periodic stats retrieval.
*/
disableStats()
{
logger.debug('disableStats()');
if (this._closed)
{
logger.error('disableStats() | Consumer closed');
return;
}
if (!this._statsEnabled)
return;
this._statsEnabled = false;
clearInterval(this._statsInterval);
}
_handleWorkerNotifications()
{
// Subscribe to notifications.
......
......@@ -263,33 +263,6 @@ class Producer extends EnhancedEventEmitter
});
}
/**
* Get the Producer stats.
*
* @return {Promise}
*/
getStats()
{
logger.debug('getStats()');
if (this._closed)
return Promise.reject(new errors.InvalidStateError('Producer closed'));
return this._channel.request('producer.getStats', this._internal)
.then((data) =>
{
logger.debug('"producer.getStats" request succeeded');
return data;
})
.catch((error) =>
{
logger.error('"producer.getStats" request failed: %s', String(error));
throw error;
});
}
/**
* Pauses receiving media.
*
......@@ -339,67 +312,6 @@ class Producer extends EnhancedEventEmitter
return this.paused;
}
/**
* Enables periodic stats retrieval.
*
*/
enableStats(appData)
{
logger.debug('enableStats()');
const { interval } = appData;
if (this._closed)
{
logger.error('enableStats() | Producer closed');
return;
}
if (this._statsEnabled)
return;
this._statsEnabled = true;
this._statsInterval = setInterval(() =>
{
if (this.paused)
return;
this.getStats()
.then((stats) =>
{
this.emit('@notify', 'producerStats', { id: this.id, stats });
})
.catch((error) =>
{
logger.error('"getStats" failed: %s', String(error));
});
}, interval * 1000);
}
/**
* Disables periodic stats retrieval.
*
*/
disableStats()
{
logger.debug('disableStats()');
if (this._closed)
{
logger.error('disableStats() | Producer closed');
return;
}
if (!this._statsEnabled)
return;
this._statsEnabled = false;
clearInterval(this._statsInterval);
}
/**
* The remote Producer was paused.
* Invoked via remote notification.
......@@ -589,6 +501,92 @@ class Producer extends EnhancedEventEmitter
});
}
/**
* Get the Producer stats.
*
* @return {Promise}
*/
getStats()
{
logger.debug('getStats()');
if (this._closed)
return Promise.reject(new errors.InvalidStateError('Producer closed'));
return this._channel.request('producer.getStats', this._internal)
.then((data) =>
{
logger.debug('"producer.getStats" request succeeded');
return data;
})
.catch((error) =>
{
logger.error('"producer.getStats" request failed: %s', String(error));
throw error;
});
}
/**
* Enables periodic stats retrieval.
*/
enableStats(options)
{
logger.debug('enableStats()');
const { interval } = options;
if (this._closed)
{
logger.error('enableStats() | Producer closed');
return;
}
if (this._statsEnabled)
return;
this._statsEnabled = true;
this._statsInterval = setInterval(() =>
{
if (this.paused)
return;
this.getStats()
.then((stats) =>
{
this.emit('@notify', 'producerStats', { id: this.id, stats });
})
.catch((error) =>
{
logger.error('"getStats" failed: %s', String(error));
});
}, interval * 1000);
}
/**
* Disables periodic stats retrieval.
*/
disableStats()
{
logger.debug('disableStats()');
if (this._closed)
{
logger.error('disableStats() | Producer closed');
return;
}
if (!this._statsEnabled)
return;
this._statsEnabled = false;
clearInterval(this._statsInterval);
}
_handleTransportEvents()
{
// On closure, the worker Transport closes all its Producers and the client
......
......@@ -170,64 +170,6 @@ class WebRtcTransport extends EnhancedEventEmitter
this._destroy(notifyChannel);
}
/**
* Enables periodic stats retrieval.
*
*/
enableStats(appData)
{
logger.debug('enableStats()');
const { interval } = appData;
if (this._closed)
{
logger.error('enableStats() | WebRtcTransport closed');
return;
}
if (this._statsEnabled)
return;
this._statsEnabled = true;
this._statsInterval = setInterval(() =>
{
this.getStats()
.then((stats) =>
{
this.emit('@notify', 'transportStats', { id: this.id, stats });
})
.catch((error) =>
{
logger.error('"getStats" request failed: %s', String(error));
});
}, interval * 1000);
}
/**
* Disables periodic stats retrieval.
*
*/
disableStats()
{
logger.debug('disableStats()');
if (this._closed)
{
logger.error('disableStats() | WebRtcTransport closed');
return;
}
if (!this._statsEnabled)
return;
this._statsEnabled = false;
clearInterval(this._statsInterval);
}
/**
* Remote WebRtcTransport was closed.
* Invoked via remote notification.
......@@ -306,33 +248,6 @@ class WebRtcTransport extends EnhancedEventEmitter
});
}
/**
* Get the WebRtcTransport stats.
*
* @return {Promise}
*/
getStats()
{
logger.debug('getStats()');
if (this._closed)
return Promise.reject(new errors.InvalidStateError('WebRtcTransport closed'));
return this._channel.request('transport.getStats', this._internal)
.then((data) =>
{
logger.debug('"transport.getStats" request succeeded');
return data;
})
.catch((error) =>
{
logger.error('"transport.getStats" request failed: %s', String(error));
throw error;
});
}
/**
* Provide the remote DTLS parameters.
*
......@@ -434,6 +349,89 @@ class WebRtcTransport extends EnhancedEventEmitter
});
}
/**
* Get the WebRtcTransport stats.
*
* @return {Promise}
*/
getStats()
{
logger.debug('getStats()');
if (this._closed)
return Promise.reject(new errors.InvalidStateError('WebRtcTransport closed'));
return this._channel.request('transport.getStats', this._internal)
.then((data) =>
{
logger.debug('"transport.getStats" request succeeded');
return data;
})
.catch((error) =>
{
logger.error('"transport.getStats" request failed: %s', String(error));
throw error;
});
}
/**
* Enables periodic stats retrieval.
*/
enableStats(options)
{
logger.debug('enableStats()');
const { interval } = options;
if (this._closed)
{
logger.error('enableStats() | WebRtcTransport closed');
return;
}
if (this._statsEnabled)
return;
this._statsEnabled = true;
this._statsInterval = setInterval(() =>
{
this.getStats()
.then((stats) =>
{
this.emit('@notify', 'transportStats', { id: this.id, stats });
})
.catch((error) =>
{
logger.error('"getStats" request failed: %s', String(error));
});
}, interval * 1000);
}
/**
* Disables periodic stats retrieval.
*/
disableStats()
{
logger.debug('disableStats()');
if (this._closed)
{
logger.error('disableStats() | WebRtcTransport closed');
return;
}
if (!this._statsEnabled)
return;
this._statsEnabled = false;
clearInterval(this._statsInterval);
}
/**
* Tell the WebRtcTransport to start mirroring incoming data.
*
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论