Adds a MemberList module and (currently disabled) code to show the dialpad button.
This commit is contained in:
parent
8075d0a0fd
commit
0efcbdcd37
2
app.js
2
app.js
|
@ -16,6 +16,7 @@ var APP =
|
|||
this.translation = require("./modules/translation/translation");
|
||||
this.settings = require("./modules/settings/Settings");
|
||||
this.DTMF = require("./modules/DTMF/DTMF");
|
||||
this.members = require("./modules/members/MemberList");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -30,6 +31,7 @@ function init() {
|
|||
APP.desktopsharing.init();
|
||||
|
||||
APP.keyboardshortcut.init();
|
||||
APP.members.start();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ var DesktopSharingEventTypes
|
|||
var RTCEvents = require("../../service/RTC/RTCEvents");
|
||||
var StreamEventTypes = require("../../service/RTC/StreamEventTypes");
|
||||
var XMPPEvents = require("../../service/xmpp/XMPPEvents");
|
||||
var MemberEvents = require("../../service/members/Events");
|
||||
|
||||
var eventEmitter = new EventEmitter();
|
||||
var roomName = null;
|
||||
|
@ -224,6 +225,8 @@ function registerListeners() {
|
|||
VideoLayout.setDeviceAvailabilityIcons(resource, devices);
|
||||
});
|
||||
|
||||
APP.members.addListener(MemberEvents.DTMF_SUPPORT_CHANGED,
|
||||
onDtmfSupportChanged);
|
||||
}
|
||||
|
||||
|
||||
|
@ -502,6 +505,16 @@ function onPasswordRequired(callback) {
|
|||
':input:first'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The dialpad button is shown iff there is at least one member that supports
|
||||
* DTMF (e.g. jigasi).
|
||||
*/
|
||||
function onDtmfSupportChanged(dtmfSupport) {
|
||||
//TODO: enable when the UI is ready
|
||||
//Toolbar.showDialPadButton(dtmfSupport);
|
||||
}
|
||||
|
||||
function onMucMemberJoined(jid, id, displayName) {
|
||||
messageHandler.notify(displayName,'notify.somebody',
|
||||
'connected',
|
||||
|
|
|
@ -0,0 +1,123 @@
|
|||
/* global APP */
|
||||
|
||||
/**
|
||||
* This module is meant to (eventually) contain and manage all information
|
||||
* about members/participants of the conference, so that other modules don't
|
||||
* have to do it on their own, and so that other modules can access members'
|
||||
* information from a single place.
|
||||
*
|
||||
* Currently this module only manages information about the support of jingle
|
||||
* DTMF of the members. Other fields, as well as accessor methods are meant to
|
||||
* be added as needed.
|
||||
*/
|
||||
|
||||
var XMPPEvents = require("../../service/xmpp/XMPPEvents");
|
||||
var Events = require("../../service/members/Events");
|
||||
var EventEmitter = require("events");
|
||||
|
||||
var eventEmitter = new EventEmitter();
|
||||
|
||||
/**
|
||||
* The actual container.
|
||||
*/
|
||||
var members = {};
|
||||
|
||||
/**
|
||||
* There is at least one member that supports DTMF (i.e. is jigasi).
|
||||
*/
|
||||
var atLeastOneDtmf = false;
|
||||
|
||||
|
||||
function registerListeners() {
|
||||
APP.xmpp.addListener(XMPPEvents.MUC_MEMBER_JOINED, onMucMemberJoined);
|
||||
APP.xmpp.addListener(XMPPEvents.MUC_MEMBER_LEFT, onMucMemberLeft);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a new member joining the MUC.
|
||||
*/
|
||||
function onMucMemberJoined(jid, id, displayName) {
|
||||
var member = {
|
||||
displayName: displayName
|
||||
};
|
||||
|
||||
APP.xmpp.getConnection().disco.info(
|
||||
jid, "" /* node */, function(iq) { onDiscoInfoReceived(jid, iq); });
|
||||
|
||||
members[jid] = member;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a member leaving the MUC.
|
||||
*/
|
||||
function onMucMemberLeft(jid) {
|
||||
delete members[jid];
|
||||
updateAtLeastOneDtmf();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the reception of a disco#info packet from a particular JID.
|
||||
* @param jid the JID sending the packet.
|
||||
* @param iq the packet.
|
||||
*/
|
||||
function onDiscoInfoReceived(jid, iq) {
|
||||
if (!members[jid])
|
||||
return;
|
||||
|
||||
var supportsDtmf
|
||||
= $(iq).find('>query>feature[var="urn:xmpp:jingle:dtmf:0"]').length > 0;
|
||||
updateDtmf(jid, supportsDtmf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the 'supportsDtmf' field for a member.
|
||||
* @param jid the jid of the member.
|
||||
* @param newValue the new value for the 'supportsDtmf' field.
|
||||
*/
|
||||
function updateDtmf(jid, newValue) {
|
||||
var oldValue = members[jid].supportsDtmf;
|
||||
members[jid].supportsDtmf = newValue;
|
||||
|
||||
if (newValue != oldValue) {
|
||||
updateAtLeastOneDtmf();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks each member's 'supportsDtmf' field and updates
|
||||
* 'atLastOneSupportsDtmf'.
|
||||
*/
|
||||
function updateAtLeastOneDtmf(){
|
||||
var newAtLeastOneDtmf = false;
|
||||
for (var key in members) {
|
||||
if (typeof members[key].supportsDtmf !== 'undefined'
|
||||
&& members[key].supportsDtmf) {
|
||||
newAtLeastOneDtmf= true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (atLeastOneDtmf != newAtLeastOneDtmf) {
|
||||
atLeastOneDtmf = newAtLeastOneDtmf;
|
||||
eventEmitter.emit(Events.DTMF_SUPPORT_CHANGED, atLeastOneDtmf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Exported interface.
|
||||
*/
|
||||
var Members = {
|
||||
start: function(){
|
||||
registerListeners();
|
||||
},
|
||||
addListener: function(type, listener)
|
||||
{
|
||||
eventEmitter.on(type, listener);
|
||||
},
|
||||
removeListener: function (type, listener) {
|
||||
eventEmitter.removeListener(type, listener);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = Members;
|
|
@ -0,0 +1,5 @@
|
|||
var Events = {
|
||||
DTMF_SUPPORT_CHANGED: "members.dtmf_support_changed"
|
||||
};
|
||||
|
||||
module.exports = Events;
|
Loading…
Reference in New Issue