do not use members module

This commit is contained in:
isymchych 2015-12-03 15:11:01 +02:00
parent 272cfea493
commit 09aa9482c0
13 changed files with 929 additions and 1243 deletions

385
app.js
View File

@ -1,5 +1,4 @@
/* jshint -W117 */
/* global JitsiMeetJS */
/* global $, JitsiMeetJS, config, Promise */
/* application specific logic */
require("jquery");
@ -13,66 +12,41 @@ window.toastr = require("toastr");
require("jQuery-Impromptu");
require("autosize");
var CQEvents = require('./service/connectionquality/CQEvents');
var UIEvents = require('./service/UI/UIEvents');
var Commands = {
CONNECTION_QUALITY: "connectionQuality",
EMAIL: "email"
};
function createConference(connection, room) {
var localTracks = [];
var remoteTracks = {};
return {
muteAudio: function (mute) {
},
muteVideo: function (mute) {
},
toggleAudioMuted: function () {
APP.UI.setAudioMuted(muted);
},
toggleVideoMuted: function () {
APP.UI.setVideoMuted(muted);
},
setNickname: function (nickname) {
APP.settings.setDisplayName(nickname);
room.setDisplayName(nickname);
},
setStartMuted: function (audio, video) {
// FIXME room.setStartMuted
},
sendMessage: function (message) {
room.sendTextMessage(message);
},
isModerator: function () {
return false;
},
localId: function () {
return room.myUserId();
},
isLocalId: function (id) {
return id === this.localId();
}
};
}
var APP = {
JitsiMeetJS: JitsiMeetJS,
init: function () {
this.JitsiMeetJS.init();
this.JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.TRACE);
this.conference = null;
JitsiMeetJS.init();
JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.TRACE);
this.conference = {
localId: undefined,
isModerator: false,
membersCount: 0,
audioMuted: false,
videoMuted: false,
isLocalId: function (id) {
return this.localId === id;
},
muteAudio: function (mute) {
APP.UI.eventEmitter.emit(UIEvents.AUDIO_MUTED, mute);
},
toggleAudioMuted: function () {
this.muteAudio(!this.audioMuted);
},
muteVideo: function (mute) {
APP.UI.eventEmitter.emit(UIEvents.VIDEO_MUTED, mute);
},
toggleVideoMuted: function () {
this.muteVideo(!this.videoMuted);
}
};
this.UI = require("./modules/UI/UI");
this.API = require("./modules/API/API");
@ -85,74 +59,120 @@ var APP = {
require("./modules/keyboardshortcut/keyboardshortcut");
this.translation = require("./modules/translation/translation");
this.settings = require("./modules/settings/Settings");
//this.DTMF = require("./modules/DTMF/DTMF");
this.members = require("./modules/members/MemberList");
this.configFetch = require("./modules/config/HttpConfigFetch");
}
};
var ConnectionEvents = JitsiMeetJS.events.connection;
var ConnectionErrors = JitsiMeetJS.errors.connection;
function connect() {
var connection = new APP.JitsiMeetJS.JitsiConnection(null, null, {
var connection = new JitsiMeetJS.JitsiConnection(null, null, {
hosts: config.hosts,
bosh: config.bosh,
clientNode: config.clientNode
});
var events = APP.JitsiMeetJS.events.connection;
return new Promise(function (resolve, reject) {
var onConnectionSuccess = function () {
var handlers = {};
var unsubscribe = function () {
Object.keys(handlers).forEach(function (event) {
connection.removeEventListener(event, handlers[event]);
});
};
handlers[ConnectionEvents.CONNECTION_ESTABLISHED] = function () {
console.log('CONNECTED');
unsubscribe();
resolve(connection);
};
var onConnectionFailed = function () {
console.error('CONNECTION FAILED');
reject();
var listenForFailure = function (event) {
handlers[event] = function () {
// convert arguments to array
var args = Array.prototype.slice.call(arguments);
args.unshift(event);
// [event, ...params]
console.error('CONNECTION FAILED:', args);
unsubscribe();
reject(args);
};
};
var onDisconnect = function () {
console.log('DISCONNECT');
connection.removeEventListener(
events.CONNECTION_ESTABLISHED, onConnectionSuccess
);
connection.removeEventListener(
events.CONNECTION_FAILED, onConnectionFailed
);
connection.removeEventListener(
events.CONNECTION_DISCONNECTED, onDisconnect
);
};
listenForFailure(ConnectionEvents.CONNECTION_FAILED);
listenForFailure(ConnectionErrors.PASSWORD_REQUIRED);
listenForFailure(ConnectionErrors.CONNECTION_ERROR);
listenForFailure(ConnectionErrors.OTHER_ERRORS);
connection.addEventListener(
events.CONNECTION_ESTABLISHED, onConnectionSuccess
);
connection.addEventListener(
events.CONNECTION_FAILED, onConnectionFailed
);
connection.addEventListener(
events.CONNECTION_DISCONNECTED, onDisconnect
);
// install event listeners
Object.keys(handlers).forEach(function (event) {
connection.addEventListener(event, handlers[event]);
});
connection.connect();
}).catch(function (errType, msg) {
// TODO handle OTHER_ERROR only
APP.UI.notifyConnectionFailed(msg);
}).catch(function (err) {
if (err[0] === ConnectionErrors.PASSWORD_REQUIRED) {
// FIXME ask for password and try again
return connect();
}
console.error('FAILED TO CONNECT', err);
APP.UI.notifyConnectionFailed(err[1]);
// rethrow
throw new Error(errType);
throw new Error(err[0]);
});
}
var ConferenceEvents = APP.JitsiMeetJS.events.conference;
var ConferenceErrors = APP.JitsiMeetJS.errors.conference;
var ConferenceEvents = JitsiMeetJS.events.conference;
var ConferenceErrors = JitsiMeetJS.errors.conference;
function initConference(connection, roomName) {
var room = connection.initJitsiConference(roomName, {
openSctp: config.openSctp,
disableAudioLevels: config.disableAudioLevels
});
var conf = createConference(connection, room);
var users = {};
var localTracks = [];
APP.conference.localId = room.myUserId();
Object.defineProperty(APP.conference, "membersCount", {
get: function () {
return Object.keys(users).length; // FIXME maybe +1?
}
});
room.on(ConferenceEvents.USER_JOINED, function (id) {
users[id] = {
displayName: undefined,
tracks: []
};
// FIXME email???
APP.UI.addUser(id);
});
room.on(ConferenceEvents.USER_LEFT, function (id) {
delete users[id];
APP.UI.removeUser(id);
});
room.on(ConferenceEvents.TRACK_MUTE_CHANGED, function (track) {
// FIXME handle mute
});
room.on(ConferenceEvents.TRACK_AUDIO_LEVEL_CHANGED, function (id, lvl) {
APP.UI.setAudioLevel(id, lvl);
});
APP.UI.addListener(UIEvents.AUDIO_MUTED, function (muted) {
// FIXME mute or unmute
APP.UI.setAudioMuted(muted);
APP.conference.audioMuted = muted;
});
APP.UI.addListener(UIEvents.VIDEO_MUTED, function (muted) {
// FIXME mute or unmute
APP.UI.setVideoMuted(muted);
APP.conference.videoMuted = muted;
});
room.on(ConferenceEvents.IN_LAST_N_CHANGED, function (inLastN) {
if (config.muteLocalVideoIfNotInLastN) {
@ -161,69 +181,21 @@ function initConference(connection, roomName) {
// APP.UI.markVideoMuted(true/false);
}
});
room.on(ConferenceEvents.LAST_N_ENDPOINTS_CHANGED, function (ids) {
APP.UI.handleLastNEndpoints(ids);
});
room.on(ConferenceEvents.ACTIVE_SPEAKER_CHANGED, function (id) {
APP.UI.markDominantSpiker(id);
});
room.on(
ConferenceEvents.ACTIVE_SPEAKER_CHANGED,
function (id) {
APP.UI.markDominantSpiker(id);
}
);
room.on(
ConferenceEvents.LAST_N_ENDPOINTS_CHANGED,
function (ids) {
APP.UI.handleLastNEndpoints(ids);
}
);
room.on(
ConferenceEvents.DISPLAY_NAME_CHANGED,
function (id, displayName) {
APP.UI.changeDisplayName(id, displayName);
}
);
room.on(ConferenceEvents.CONNECTION_INTERRUPTED, function () {
APP.UI.markVideoInterrupted(true);
});
room.on(ConferenceEvents.CONNECTION_RESTORED, function () {
APP.UI.markVideoInterrupted(false);
});
room.on(
ConferenceEvents.USER_JOINED,
function (id) {
// FIXME email???
APP.UI.addUser(id);
}
);
room.on(
ConferenceEvents.USER_LEFT,
function (id) {
APP.UI.removeUser(id);
}
);
room.on(
ConferenceEvents.TRACK_MUTE_CHANGED,
function (track) {
// FIXME handle mute
}
);
room.on(
ConferenceEvents.TRACK_AUDIO_LEVEL_CHANGED,
function (id, lvl) {
APP.UI.setAudioLevel(id, lvl);
}
);
room.on(
ConferenceEvents.CONNECTION_INTERRUPTED,
function () {
APP.UI.markVideoInterrupted(true);
}
);
room.on(
ConferenceEvents.CONNECTION_RESTORED,
function () {
APP.UI.markVideoInterrupted(false);
}
);
APP.connectionquality.addListener(
CQEvents.LOCALSTATS_UPDATED,
@ -239,20 +211,14 @@ function initConference(connection, roomName) {
});
}
);
APP.connectionquality.addListener(
CQEvents.STOP,
function () {
APP.UI.hideStats();
room.removeCommand(Commands.CONNECTION_QUALITY);
}
);
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) {
@ -260,7 +226,8 @@ function initConference(connection, roomName) {
}
);
// share email with other users
// share email with other users
function sendEmail(email) {
room.sendCommand(Commands.EMAIL, {
value: email,
@ -270,38 +237,51 @@ function initConference(connection, roomName) {
});
}
var email = APP.settings.getEmail();
email && sendEmail(email);
APP.UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
APP.settings.setEmail(email);
APP.UI.setUserAvatar(room.myUserId(), data.value);
APP.UI.setUserAvatar(room.myUserId(), email);
sendEmail(email);
});
var email = APP.settings.getEmail();
if (email) {
sendEmail(APP.settings.getEmail());
}
room.addCommandListener(Commands.EMAIL, function (data) {
APP.UI.setUserAvatar(data.attributes.id, data.value);
});
room.on(ConferenceEvents.DISPLAY_NAME_CHANGED, function (id, displayName) {
APP.UI.changeDisplayName(id, displayName);
});
APP.UI.addListener(UIEvents.NICKNAME_CHANGED, function (nickname) {
APP.settings.setDisplayName(nickname);
room.setDisplayName(nickname);
});
APP.UI.addListener(UIEvents.MESSAGE_CREATED, function (message) {
room.sendTextMessage(message);
});
room.on(ConferenceErrors.PASSWORD_REQUIRED, function () {
// FIXME handle
});
room.on(ConferenceErrors.CONNECTION_ERROR, function () {
// FIXME handle
});
APP.UI.addListener(
UIEvents.START_MUTED_CHANGED,
function (startAudioMuted, startVideoMuted) {
// FIXME start muted
}
);
return new Promise(function (resolve, reject) {
room.on(
ConferenceEvents.CONFERENCE_JOINED,
function () {
resolve(conf);
}
);
room.on(
ConferenceErrors.PASSWORD_REQUIRED,
function () {
// FIXME handle
reject();
}
);
room.on(
ConferenceErrors.CONNECTION_ERROR,
function () {
// FIXME handle
reject();
resolve();
}
);
APP.UI.closeAuthenticationDialog();
@ -310,45 +290,35 @@ function initConference(connection, roomName) {
var nick = APP.UI.askForNickname();
}
room.join();
}).catch(function (err) {
if (err[0] === ConferenceErrors.PASSWORD_REQUIRED) {
// FIXME ask for password and try again
return initConference(connection, roomName);
}
// FIXME else notify that we cannot conenct to the room
throw new Error(err[0]);
});
}
function init() {
connect().then(function (connection) {
return initConference(connection, APP.UI.generateRoomName());
}).then(function (conference) {
APP.conference = conference;
}).then(function () {
APP.UI.start();
// FIXME find own jid
APP.UI.initConference("asdfasdf");
APP.UI.addListener(UIEvents.NICKNAME_CHANGED, function (nickname) {
APP.conference.setNickname(nickname);
});
APP.UI.addListener(UIEvents.MESSAGE_CREATED, function (message) {
APP.conference.sendMessage(message);
});
APP.UI.initConference();
APP.UI.addListener(UIEvents.LANG_CHANGED, function (language) {
APP.translation.setLanguage(language);
APP.settings.setLanguage(language);
});
APP.UI.addListener(
UIEvents.START_MUTED_CHANGED,
function (startAudioMuted, startVideoMuted) {
APP.conference.setStartMuted(startAudioMuted, startVideoMuted);
}
);
APP.desktopsharing.init();
APP.statistics.start();
APP.connectionquality.init();
APP.keyboardshortcut.init();
APP.members.start();
});
}
@ -397,7 +367,7 @@ $(document).ready(function () {
APP.translation.init();
if(APP.API.isEnabled()) {
if (APP.API.isEnabled()) {
APP.API.init();
}
@ -405,8 +375,9 @@ $(document).ready(function () {
});
$(window).bind('beforeunload', function () {
if(APP.API.isEnabled())
if (APP.API.isEnabled()) {
APP.API.dispose();
}
});
module.exports = APP;

File diff suppressed because it is too large Load Diff

View File

@ -27,10 +27,10 @@ var DesktopSharingEventTypes
= require("../../service/desktopsharing/DesktopSharingEventTypes");
var StatisticsEvents = require("../../service/statistics/Events");
var UIEvents = require("../../service/UI/UIEvents");
var MemberEvents = require("../../service/members/Events");
var Feedback = require("./Feedback");
var eventEmitter = new EventEmitter();
UI.eventEmitter = eventEmitter;
var roomNode = null;
var roomName = null;
@ -94,7 +94,7 @@ function setupChat() {
}
function setupToolbars() {
Toolbar.init(UI);
Toolbar.init(eventEmitter);
Toolbar.setupButtonsFromConfig();
BottomToolbar.init(eventEmitter);
}
@ -135,7 +135,8 @@ UI.changeDisplayName = function (id, displayName) {
VideoLayout.onDisplayNameChanged(id, displayName);
};
UI.initConference = function (id) {
UI.initConference = function () {
var id = APP.conference.localId;
Toolbar.updateRoomUrl(window.location.href);
var meHTML = APP.translation.generateTranslationHTML("me");
var settings = Settings.getSettings();
@ -172,21 +173,20 @@ function registerListeners() {
});
UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
UI.setUserAvatar(APP.conference.localId(), email);
UI.setUserAvatar(APP.conference.localId, email);
});
}
function onResize() {
Chat.resizeChat();
VideoLayout.resizeLargeVideoContainer();
}
function bindEvents() {
/**
* Resizes and repositions videos in full screen mode.
*/
$(document).on('webkitfullscreenchange mozfullscreenchange fullscreenchange',
onResize);
function onResize() {
Chat.resizeChat();
VideoLayout.resizeLargeVideoContainer();
}
// Resize and reposition videos in full screen mode.
$(document).on(
'webkitfullscreenchange mozfullscreenchange fullscreenchange', onResize
);
$(window).resize(onResize);
}
@ -386,7 +386,7 @@ UI.addUser = function (jid, id, displayName) {
);
if (!config.startAudioMuted ||
config.startAudioMuted > APP.members.size())
config.startAudioMuted > APP.conference.membersCount)
UIUtil.playSoundNotification('userJoined');
// Configure avatar
@ -404,7 +404,7 @@ UI.removeUser = function (jid) {
'disconnected',
'notify.disconnected');
if (!config.startAudioMuted ||
config.startAudioMuted > APP.members.size()) {
config.startAudioMuted > APP.conference.membersCount) {
UIUtil.playSoundNotification('userLeft');
}

View File

@ -109,7 +109,7 @@ var AudioLevels = (function(my) {
drawContext.drawImage(canvasCache, 0, 0);
if(resourceJid === AudioLevels.LOCAL_LEVEL) {
resourceJid = APP.conference.localId();
resourceJid = APP.conference.localId;
if (!resourceJid) {
return;
}
@ -223,11 +223,9 @@ var AudioLevels = (function(my) {
*/
function getVideoSpanId(resourceJid) {
var videoSpanId = null;
if (resourceJid === AudioLevels.LOCAL_LEVEL ||
(APP.conference.localId() && resourceJid === APP.conference.localId())) {
if (resourceJid === AudioLevels.LOCAL_LEVEL || APP.conference.isLocalId(resourceJid)) {
videoSpanId = 'localVideoContainer';
}
else {
} else {
videoSpanId = 'participant_' + resourceJid;
}

View File

@ -171,7 +171,7 @@ var ContactList = {
onDisplayNameChange: function (id, displayName) {
if (id === 'localVideoContainer') {
id = APP.conference.localId();
id = APP.conference.localId;
}
var contactName = $('#contacts #' + id + '>p');

View File

@ -36,7 +36,7 @@ var SettingsMenu = {
}
});
if (APP.conference.isModerator()) {
if (APP.conference.isModerator) {
startMutedSelector.css("display", "block");
} else {
startMutedSelector.css("display", "none");
@ -48,7 +48,7 @@ var SettingsMenu = {
},
onRoleChanged: function () {
if(APP.conference.isModerator()) {
if(APP.conference.isModerator) {
$("#startMutedOptions").css("display", "block");
}
else {

View File

@ -1,5 +1,4 @@
/* global APP, $, buttonClick, config, lockRoom, interfaceConfig, setSharedKey,
Util */
/* global APP, $, config, interfaceConfig */
/* jshint -W101 */
var messageHandler = require("../util/MessageHandler");
var BottomToolbar = require("./BottomToolbar");
@ -12,28 +11,31 @@ var AuthenticationEvents
= require("../../../service/authentication/AuthenticationEvents");
var AnalyticsAdapter = require("../../statistics/AnalyticsAdapter");
var Feedback = require("../Feedback");
var UIEvents = require("../../../service/UI/UIEvents");
var roomUrl = null;
var sharedKey = '';
var UI = null;
var recordingToaster = null;
var emitter = null;
var buttonHandlers = {
"toolbar_button_mute": function () {
if (APP.RTC.localAudio.isMuted()) {
AnalyticsAdapter.sendEvent('toolbar.audio.unmuted');
emitter.emit(UIEvents.AUDIO_MUTED, false);
} else {
AnalyticsAdapter.sendEvent('toolbar.audio.muted');
emitter.emit(UIEvents.AUDIO_MUTED, true);
}
return APP.conference.toggleAudioMuted();
},
"toolbar_button_camera": function () {
if (APP.RTC.localVideo.isMuted()) {
AnalyticsAdapter.sendEvent('toolbar.video.enabled');
emitter.emit(UIEvents.VIDEO_MUTED, false);
} else {
AnalyticsAdapter.sendEvent('toolbar.video.disabled');
emitter.emit(UIEvents.VIDEO_MUTED, true);
}
return APP.conference.toggleVideoMuted();
},
/*"toolbar_button_authentication": function () {
return Toolbar.authenticateClicked();
@ -299,7 +301,7 @@ function callSipButtonClicked() {
var numberInput = f.sipNumber;
if (numberInput) {
APP.xmpp.dial(
numberInput, 'fromnumber', UI.getRoomName(), sharedKey);
numberInput, 'fromnumber', APP.UI.getRoomName(), sharedKey);
}
}
},
@ -309,12 +311,12 @@ function callSipButtonClicked() {
var Toolbar = (function (my) {
my.init = function (ui) {
my.init = function (eventEmitter) {
emitter = eventEmitter;
UIUtil.hideDisabledButtons(defaultToolbarButtons);
for(var k in buttonHandlers)
$("#" + k).click(buttonHandlers[k]);
UI = ui;
// Update login info
APP.xmpp.addListener(
AuthenticationEvents.IDENTITY_UPDATED,
@ -353,12 +355,12 @@ var Toolbar = (function (my) {
}
// Get authentication URL
if (!APP.xmpp.isMUCJoined()) {
APP.xmpp.getLoginUrl(UI.getRoomName(), function (url) {
APP.xmpp.getLoginUrl(APP.UI.getRoomName(), function (url) {
// If conference has not been started yet - redirect to login page
window.location.href = url;
});
} else {
APP.xmpp.getPopupLoginUrl(UI.getRoomName(), function (url) {
APP.xmpp.getPopupLoginUrl(APP.UI.getRoomName(), function (url) {
// Otherwise - open popup with authentication URL
var authenticationWindow = Authentication.createAuthenticationWindow(
function () {

View File

@ -1,5 +1,4 @@
/* global APP, config, $, interfaceConfig, Moderator,
DesktopStreaming.showDesktopSharingButton */
/* global APP, config, $, interfaceConfig */
var toolbarTimeoutObject,
toolbarTimeout = interfaceConfig.INITIAL_TOOLBAR_TIMEOUT,
@ -75,12 +74,6 @@ var ToolbarToggler = {
toolbarTimeout = interfaceConfig.TOOLBAR_TIMEOUT;
}
if (APP.conference.isModerator()) {
// TODO: Enable settings functionality.
// Need to uncomment the settings button in index.html.
// $('#settingsButton').css({visibility:"visible"});
}
// Show/hide desktop sharing button
showDesktopSharingButton();
},

View File

@ -56,9 +56,6 @@ var VideoLayout = (function (my) {
};
my.changeLocalAudio = function(stream, isMuted) {
if (isMuted) { // FIXME remove this?
APP.conference.muteAudio(true);
}
APP.RTC.attachMediaStream($('#localAudio'), stream.getOriginalStream());
var localAudio = document.getElementById('localAudio');
// Writing volume not allowed in IE

View File

@ -26,9 +26,7 @@ function initShortcutHandlers() {
84: {
character: "T",
function: function() {
if(!APP.RTC.localAudio.isMuted()) {
APP.conference.toggleAudioMuted();
}
APP.conference.muteAudio(true);
}
},
86: {
@ -67,9 +65,7 @@ var KeyboardShortcut = {
$(":focus").is("input[type=password]") ||
$(":focus").is("textarea"))) {
if(e.which === "T".charCodeAt(0)) {
if(APP.RTC.localAudio.isMuted()) {
APP.conference.toggleAudioMuted();
}
APP.conference.muteAudio(true);
}
}
};

View File

@ -1,128 +0,0 @@
/* global APP, require, $ */
/**
* 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);
},
size: function () {
return Object.keys(members).length;
},
getMembers: function () {
return members;
}
};
module.exports = Members;

View File

@ -19,6 +19,8 @@ var UIEvents = {
* Notifies that "start muted" settings changed.
*/
START_MUTED_CHANGED: "UI.start_muted_changed",
AUDIO_MUTED: "UI.audio_muted",
VIDEO_MUTED: "UI.video_muted",
/**
* Notifies interested parties when the film strip (remote video's panel)
* is hidden (toggled) or shown (un-toggled).

View File

@ -1,5 +0,0 @@
var Events = {
DTMF_SUPPORT_CHANGED: "members.dtmf_support_changed"
};
module.exports = Events;