Sends endpoint information in COLIBRI messages (in 'endpoint' children

of 'conference').
This commit is contained in:
Boris Grozev 2014-07-23 09:12:36 +02:00
parent 1d3df3c41c
commit 256694b966
2 changed files with 100 additions and 1 deletions

16
app.js
View File

@ -632,6 +632,10 @@ $(document).bind('joined.muc', function (event, jid, info) {
if (Object.keys(connection.emuc.members).length < 1) {
focus = new ColibriFocus(connection, config.hosts.bridge);
if (nickname !== null) {
focus.setEndpointDisplayName(connection.emuc.myroomjid,
nickname);
}
showRecordingButton(false);
}
@ -710,6 +714,10 @@ $(document).bind('left.muc', function (event, jid) {
&& !sessionTerminated) {
console.log('welcome to our new focus... myself');
focus = new ColibriFocus(connection, config.hosts.bridge);
if (nickname !== null) {
focus.setEndpointDisplayName(connection.emuc.myroomjid,
nickname);
}
if (Object.keys(connection.emuc.members).length > 0) {
focus.makeConference(Object.keys(connection.emuc.members));
@ -723,6 +731,10 @@ $(document).bind('left.muc', function (event, jid) {
// problems with reinit
disposeConference();
focus = new ColibriFocus(connection, config.hosts.bridge);
if (nickname !== null) {
focus.setEndpointDisplayName(connection.emuc.myroomjid,
nickname);
}
showRecordingButton(false);
}
if (connection.emuc.getPrezi(jid)) {
@ -776,6 +788,10 @@ $(document).bind('presence.muc', function (event, jid, info, pres) {
'participant_' + Strophe.getResourceFromJid(jid),
info.displayName);
}
if (focus !== null && info.displayName !== null) {
focus.setEndpointDisplayName(jid, info.displayName);
}
});
$(document).bind('passwordrequired.muc', function (event, jid) {

View File

@ -84,6 +84,10 @@ function ColibriFocus(connection, bridgejid) {
this.wait = true;
this.recordingEnabled = false;
// stores information about the endpoints (i.e. display names) to
// be sent to the videobridge.
this.endpointsInfo = null;
}
// creates a conferences with an initial set of peers
@ -176,7 +180,7 @@ ColibriFocus.prototype.makeConference = function (peers) {
// the new recording state, according to the IQ.
ColibriFocus.prototype.setRecording = function(state, token, callback) {
var self = this;
var elem = $iq({to: this.bridgejid, type: 'get'});
var elem = $iq({to: this.bridgejid, type: 'set'});
elem.c('conference', {
xmlns: 'http://jitsi.org/protocol/colibri',
id: this.confid
@ -199,6 +203,74 @@ ColibriFocus.prototype.setRecording = function(state, token, callback) {
);
};
/*
* Updates the display name for an endpoint with a specific jid.
* jid: the jid associated with the endpoint.
* displayName: the new display name for the endpoint.
*/
ColibriFocus.prototype.setEndpointDisplayName = function(jid, displayName) {
var endpointId = jid.substr(1 + jid.lastIndexOf('/'));
var update = false;
if (this.endpointsInfo === null) {
this.endpointsInfo = {};
}
var endpointInfo = this.endpointsInfo[endpointId];
if ('undefined' === typeof endpointInfo) {
endpointInfo = this.endpointsInfo[endpointId] = {};
}
if (endpointInfo['displayname'] !== displayName) {
endpointInfo['displayname'] = displayName;
update = true;
}
if (update) {
this.updateEndpoints();
}
};
/*
* Sends a colibri message to the bridge that contains the
* current endpoints and their display names.
*/
ColibriFocus.prototype.updateEndpoints = function() {
if (this.confid === null
|| this.endpointsInfo === null) {
return;
}
if (this.confid === 0) {
// the colibri conference is currently initiating
var self = this;
window.setTimeout(function() { self.updateEndpoints()}, 1000);
return;
}
var elem = $iq({to: this.bridgejid, type: 'set'});
elem.c('conference', {
xmlns: 'http://jitsi.org/protocol/colibri',
id: this.confid
});
for (var id in this.endpointsInfo) {
elem.c('endpoint');
elem.attrs({ id: id,
displayname: this.endpointsInfo[id]['displayname']
});
elem.up();
}
//elem.up(); //conference
this.connection.sendIQ(
elem,
function (result) {},
function (error) { console.warn(error); }
);
};
ColibriFocus.prototype._makeConference = function () {
var self = this;
var elem = $iq({ to: this.bridgejid, type: 'get' });
@ -235,6 +307,17 @@ ColibriFocus.prototype._makeConference = function () {
}
elem.up(); // end of content
});
if (this.endpointsInfo !== null) {
for (var id in this.endpointsInfo) {
elem.c('endpoint');
elem.attrs({ id: id,
displayname: this.endpointsInfo[id]['displayname']
});
elem.up();
}
}
/*
var localSDP = new SDP(this.peerconnection.localDescription.sdp);
localSDP.media.forEach(function (media, channel) {