Merge pull request #431 from isymchych/lib-jitsi-meet

Add methods to lock/unlock conference
This commit is contained in:
hristoterezov 2015-12-14 10:14:08 +11:00
commit af6fd28d66
3 changed files with 49 additions and 2 deletions

View File

@ -6,6 +6,7 @@ var XMPPEvents = require("./service/xmpp/XMPPEvents");
var RTCEvents = require("./service/RTC/RTCEvents");
var EventEmitter = require("events");
var JitsiConferenceEvents = require("./JitsiConferenceEvents");
var JitsiConferenceErrors = require("./JitsiConferenceErrors");
var JitsiParticipant = require("./JitsiParticipant");
var Statistics = require("./modules/statistics/statistics");
var JitsiDTMFManager = require('./modules/DTMF/JitsiDTMFManager');
@ -244,6 +245,36 @@ JitsiConference.prototype.isModerator = function () {
return this.room.isModerator();
};
/**
* Set password for the room.
* @param {string} password new password for the room.
* @returns {Promise}
*/
JitsiConference.prototype.lock = function (password) {
if (!this.isModerator()) {
return Promise.reject();
}
var conference = this;
return new Promise(function (resolve, reject) {
conference.xmpp.lockRoom(password, function () {
resolve();
}, function (err) {
reject(err);
}, function () {
reject(JitsiConferenceErrors.PASSWORD_REQUIRED);
});
});
};
/**
* Remove password from the room.
* @returns {Promise}
*/
JitsiConference.prototype.unlock = function () {
return this.lock(undefined);
};
/**
* Elects the participant with the given id to be the selected participant or the speaker.
* @param id the identifier of the participant
@ -288,7 +319,7 @@ JitsiConference.prototype.onMemberJoined = function (jid, email, nick) {
var participant = new JitsiParticipant(id, this, nick);
this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, id);
this.participants[id] = participant;
this.connection.xmpp.connection.disco.info(
this.xmpp.connection.disco.info(
jid, "node", function(iq) {
participant._supportsDTMF = $(iq).find(
'>query>feature[var="urn:xmpp:jingle:dtmf:0"]').length > 0;
@ -396,7 +427,7 @@ JitsiConference.prototype.myUserId = function () {
JitsiConference.prototype.sendTones = function (tones, duration, pause) {
if (!this.dtmfManager) {
var connection = this.connection.xmpp.connection.jingle.activecall.peerconnection;
var connection = this.xmpp.connection.jingle.activecall.peerconnection;
if (!connection) {
logger.warn("cannot sendTones: no conneciton");
return;
@ -480,6 +511,9 @@ function setupListeners(conference) {
conference.eventEmitter.emit(JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED,
lastNEndpoints, endpointsEnteringLastN);
});
conference.xmpp.addListener(XMPPEvents.PASSWORD_REQUIRED, function () {
conference.eventEmitter.emit(JitsiConferenceErrors.PASSWORD_REQUIRED);
});
if(conference.statistics) {
//FIXME: Maybe remove event should not be associated with the conference.

View File

@ -7,6 +7,10 @@ var JitsiConferenceErrors = {
* Indicates that a password is required in order to join the conference.
*/
PASSWORD_REQUIRED: "conference.passwordRequired",
/**
* Indicates that password cannot be set for this conference.
*/
PASSWORD_NOT_SUPPORTED: "conference.passwordNotSupported",
/**
* Indicates that a connection error occurred when trying to join a
* conference.

View File

@ -93,6 +93,7 @@ JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.ERROR);
1. conference
- CONNECTION_ERROR - the connection with the conference is lost.
- PASSWORD_REQUIRED - that error can be passed when the connection to the conference failed. You should try to join the conference with password.
- PASSWORD_NOT_SUPPORTED - indicates that password cannot be set for this conference
- VIDEOBRIDGE_NOT_AVAILABLE - video bridge issues.
2. connection
- PASSWORD_REQUIRED - passed when the connection to the server failed. You should try to authenticate with password.
@ -225,6 +226,14 @@ The object represents a conference. We have the following methods to control the
21. isModerator() - checks if local user has "moderator" role
22. lock(password) - set password for the conference; returns Promise
- password - string password
Note: available only for moderator
23. unlock() - unset conference password; returns Promise
Note: available only for moderator
JitsiTrack
======