do not use xmpp in connectionquality module
This commit is contained in:
parent
8226914348
commit
941cd13193
38
app.js
38
app.js
|
@ -13,6 +13,10 @@ window.toastr = require("toastr");
|
||||||
require("jQuery-Impromptu");
|
require("jQuery-Impromptu");
|
||||||
require("autosize");
|
require("autosize");
|
||||||
|
|
||||||
|
var Commands = {
|
||||||
|
CONNECTION_QUALITY: "connectionQuality"
|
||||||
|
};
|
||||||
|
|
||||||
function createConference(connection, room) {
|
function createConference(connection, room) {
|
||||||
var localTracks = [];
|
var localTracks = [];
|
||||||
var remoteTracks = {};
|
var remoteTracks = {};
|
||||||
|
@ -225,6 +229,40 @@ function initConference(connection, roomName) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
APP.connectionquality.addListener(
|
||||||
|
CQEvents.LOCALSTATS_UPDATED,
|
||||||
|
function (percent, stats) {
|
||||||
|
APP.UI.updateLocalStats(percent, stats);
|
||||||
|
|
||||||
|
// send local stats to other users
|
||||||
|
room.sendCommand(Commands.CONNECTION_QUALITY, {
|
||||||
|
value: APP.connectionquality.convertToMUCStats(stats),
|
||||||
|
attributes: {
|
||||||
|
id: room.myUserId()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
APP.connectionquality.addListener(
|
||||||
|
CQEvents.STOP,
|
||||||
|
function () {
|
||||||
|
APP.UI.hideStats();
|
||||||
|
room.removeCommand(Commands.CONNECTION_QUALITY);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// listen to remote stats
|
||||||
|
room.addCommandListener(Commands.CONNECTION_QUALITY, function (data) {
|
||||||
|
APP.connectionquality.updateRemoteStats(data.attributes.id, data.value);
|
||||||
|
});
|
||||||
|
|
||||||
|
APP.connectionquality.addListener(
|
||||||
|
CQEvents.REMOTESTATS_UPDATED,
|
||||||
|
function (id, percent, stats) {
|
||||||
|
APP.UI.updateRemoteStats(id, percent, stats);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
room.on(
|
room.on(
|
||||||
|
|
|
@ -233,9 +233,7 @@ UI.start = function () {
|
||||||
// FIXME integrate logs
|
// FIXME integrate logs
|
||||||
});
|
});
|
||||||
Feedback.init();
|
Feedback.init();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$("#header").css("display", "none");
|
$("#header").css("display", "none");
|
||||||
$("#bottomToolbar").css("display", "none");
|
$("#bottomToolbar").css("display", "none");
|
||||||
$("#downloadlog").css("display", "none");
|
$("#downloadlog").css("display", "none");
|
||||||
|
@ -243,7 +241,6 @@ UI.start = function () {
|
||||||
$("#remoteVideos").css("right", "0px");
|
$("#remoteVideos").css("right", "0px");
|
||||||
messageHandler.disableNotifications();
|
messageHandler.disableNotifications();
|
||||||
$('body').popover("disable");
|
$('body').popover("disable");
|
||||||
// $("[data-toggle=popover]").popover("disable");
|
|
||||||
JitsiPopover.enabled = false;
|
JitsiPopover.enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +276,6 @@ UI.start = function () {
|
||||||
"newestOnTop": false
|
"newestOnTop": false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
SettingsMenu.init();
|
SettingsMenu.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
var EventEmitter = require("events");
|
var EventEmitter = require("events");
|
||||||
var eventEmitter = new EventEmitter();
|
var eventEmitter = new EventEmitter();
|
||||||
var CQEvents = require("../../service/connectionquality/CQEvents");
|
var CQEvents = require("../../service/connectionquality/CQEvents");
|
||||||
var XMPPEvents = require("../../service/xmpp/XMPPEvents");
|
|
||||||
var StatisticsEvents = require("../../service/statistics/Events");
|
var StatisticsEvents = require("../../service/statistics/Events");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,43 +17,6 @@ var stats = {};
|
||||||
*/
|
*/
|
||||||
var remoteStats = {};
|
var remoteStats = {};
|
||||||
|
|
||||||
/**
|
|
||||||
* Interval for sending statistics to other participants
|
|
||||||
* @type {null}
|
|
||||||
*/
|
|
||||||
var sendIntervalId = null;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Start statistics sending.
|
|
||||||
*/
|
|
||||||
function startSendingStats() {
|
|
||||||
sendStats();
|
|
||||||
sendIntervalId = setInterval(sendStats, 10000);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends statistics to other participants
|
|
||||||
*/
|
|
||||||
function sendStats() {
|
|
||||||
APP.xmpp.addToPresence("connectionQuality", convertToMUCStats(stats));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts statistics to format for sending through XMPP
|
|
||||||
* @param stats the statistics
|
|
||||||
* @returns {{bitrate_donwload: *, bitrate_uplpoad: *, packetLoss_total: *, packetLoss_download: *, packetLoss_upload: *}}
|
|
||||||
*/
|
|
||||||
function convertToMUCStats(stats) {
|
|
||||||
return {
|
|
||||||
"bitrate_download": stats.bitrate.download,
|
|
||||||
"bitrate_upload": stats.bitrate.upload,
|
|
||||||
"packetLoss_total": stats.packetLoss.total,
|
|
||||||
"packetLoss_download": stats.packetLoss.download,
|
|
||||||
"packetLoss_upload": stats.packetLoss.upload
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts statistics to format used by VideoLayout
|
* Converts statistics to format used by VideoLayout
|
||||||
* @param stats
|
* @param stats
|
||||||
|
@ -76,11 +38,12 @@ function parseMUCStats(stats) {
|
||||||
|
|
||||||
var ConnectionQuality = {
|
var ConnectionQuality = {
|
||||||
init: function () {
|
init: function () {
|
||||||
APP.xmpp.addListener(XMPPEvents.REMOTE_STATS, this.updateRemoteStats);
|
APP.statistics.addListener(
|
||||||
APP.statistics.addListener(StatisticsEvents.CONNECTION_STATS,
|
StatisticsEvents.CONNECTION_STATS, this.updateLocalStats
|
||||||
this.updateLocalStats);
|
);
|
||||||
APP.statistics.addListener(StatisticsEvents.STOP,
|
APP.statistics.addListener(
|
||||||
this.stopSendingStats);
|
StatisticsEvents.STOP, this.stopSendingStats
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,33 +53,29 @@ var ConnectionQuality = {
|
||||||
updateLocalStats: function (data) {
|
updateLocalStats: function (data) {
|
||||||
stats = data;
|
stats = data;
|
||||||
eventEmitter.emit(CQEvents.LOCALSTATS_UPDATED, 100 - stats.packetLoss.total, stats);
|
eventEmitter.emit(CQEvents.LOCALSTATS_UPDATED, 100 - stats.packetLoss.total, stats);
|
||||||
if (!sendIntervalId) {
|
|
||||||
startSendingStats();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates remote statistics
|
* Updates remote statistics
|
||||||
* @param jid the jid associated with the statistics
|
* @param id the id associated with the statistics
|
||||||
* @param data the statistics
|
* @param data the statistics
|
||||||
*/
|
*/
|
||||||
updateRemoteStats: function (jid, data) {
|
updateRemoteStats: function (id, data) {
|
||||||
if (!data || !data.packetLoss_total) {
|
if (!data || !data.packetLoss_total) {
|
||||||
eventEmitter.emit(CQEvents.REMOTESTATS_UPDATED, jid, null, null);
|
eventEmitter.emit(CQEvents.REMOTESTATS_UPDATED, id, null, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
remoteStats[jid] = parseMUCStats(data);
|
remoteStats[id] = parseMUCStats(data);
|
||||||
|
|
||||||
eventEmitter.emit(CQEvents.REMOTESTATS_UPDATED,
|
eventEmitter.emit(
|
||||||
jid, 100 - data.packetLoss_total, remoteStats[jid]);
|
CQEvents.REMOTESTATS_UPDATED, id, 100 - data.packetLoss_total, remoteStats[id]
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stops statistics sending.
|
* Stops statistics sending.
|
||||||
*/
|
*/
|
||||||
stopSendingStats: function () {
|
stopSendingStats: function () {
|
||||||
clearInterval(sendIntervalId);
|
|
||||||
sendIntervalId = null;
|
|
||||||
//notify UI about stopping statistics gathering
|
//notify UI about stopping statistics gathering
|
||||||
eventEmitter.emit(CQEvents.STOP);
|
eventEmitter.emit(CQEvents.STOP);
|
||||||
},
|
},
|
||||||
|
@ -127,11 +86,25 @@ var ConnectionQuality = {
|
||||||
getStats: function () {
|
getStats: function () {
|
||||||
return stats;
|
return stats;
|
||||||
},
|
},
|
||||||
|
|
||||||
addListener: function (type, listener) {
|
addListener: function (type, listener) {
|
||||||
eventEmitter.on(type, listener);
|
eventEmitter.on(type, listener);
|
||||||
}
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts statistics to format for sending through XMPP
|
||||||
|
* @param stats the statistics
|
||||||
|
* @returns {{bitrate_donwload: *, bitrate_uplpoad: *, packetLoss_total: *, packetLoss_download: *, packetLoss_upload: *}}
|
||||||
|
*/
|
||||||
|
convertToMUCStats: function (stats) {
|
||||||
|
return {
|
||||||
|
"bitrate_download": stats.bitrate.download,
|
||||||
|
"bitrate_upload": stats.bitrate.upload,
|
||||||
|
"packetLoss_total": stats.packetLoss.total,
|
||||||
|
"packetLoss_download": stats.packetLoss.download,
|
||||||
|
"packetLoss_upload": stats.packetLoss.upload
|
||||||
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = ConnectionQuality;
|
module.exports = ConnectionQuality;
|
Loading…
Reference in New Issue