Explorar el Código

add methods to lock/unlock conference

dev1
isymchych hace 9 años
padre
commit
9bac8dc7f2
Se han modificado 3 ficheros con 49 adiciones y 2 borrados
  1. 36
    2
      JitsiConference.js
  2. 4
    0
      JitsiConferenceErrors.js
  3. 9
    0
      doc/API.md

+ 36
- 2
JitsiConference.js Ver fichero

@@ -7,6 +7,7 @@ var StreamEventTypes = require("./service/RTC/StreamEventTypes");
7 7
 var RTCEvents = require("./service/RTC/RTCEvents");
8 8
 var EventEmitter = require("events");
9 9
 var JitsiConferenceEvents = require("./JitsiConferenceEvents");
10
+var JitsiConferenceErrors = require("./JitsiConferenceErrors");
10 11
 var JitsiParticipant = require("./JitsiParticipant");
11 12
 var Statistics = require("./modules/statistics/statistics");
12 13
 var JitsiDTMFManager = require('./modules/DTMF/JitsiDTMFManager');
@@ -211,6 +212,36 @@ JitsiConference.prototype.isModerator = function () {
211 212
     return this.room.isModerator();
212 213
 };
213 214
 
215
+/**
216
+ * Set password for the room.
217
+ * @param {string} password new password for the room.
218
+ * @returns {Promise}
219
+ */
220
+JitsiConference.prototype.lock = function (password) {
221
+  if (!this.isModerator()) {
222
+    return Promise.reject();
223
+  }
224
+
225
+  var conference = this;
226
+  return new Promise(function (resolve, reject) {
227
+    conference.xmpp.lockRoom(password, function () {
228
+      resolve();
229
+    }, function (err) {
230
+      reject(err);
231
+    }, function () {
232
+      reject(JitsiConferenceErrors.PASSWORD_REQUIRED);
233
+    });
234
+  });
235
+};
236
+
237
+/**
238
+ * Remove password from the room.
239
+ * @returns {Promise}
240
+ */
241
+JitsiConference.prototype.unlock = function () {
242
+  return this.lock(undefined);
243
+};
244
+
214 245
 /**
215 246
  * Elects the participant with the given id to be the selected participant or the speaker.
216 247
  * @param id the identifier of the participant
@@ -255,7 +286,7 @@ JitsiConference.prototype.onMemberJoined = function (jid, email, nick) {
255 286
     var participant = new JitsiParticipant(id, this, nick);
256 287
     this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, id);
257 288
     this.participants[id] = participant;
258
-    this.connection.xmpp.connection.disco.info(
289
+    this.xmpp.connection.disco.info(
259 290
         jid, "node", function(iq) {
260 291
             participant._supportsDTMF = $(iq).find(
261 292
                 '>query>feature[var="urn:xmpp:jingle:dtmf:0"]').length > 0;
@@ -344,7 +375,7 @@ JitsiConference.prototype.myUserId = function () {
344 375
 
345 376
 JitsiConference.prototype.sendTones = function (tones, duration, pause) {
346 377
     if (!this.dtmfManager) {
347
-        var connection = this.connection.xmpp.connection.jingle.activecall.peerconnection;
378
+        var connection = this.xmpp.connection.jingle.activecall.peerconnection;
348 379
         if (!connection) {
349 380
             logger.warn("cannot sendTones: no conneciton");
350 381
             return;
@@ -439,6 +470,9 @@ function setupListeners(conference) {
439 470
             conference.eventEmitter.emit(JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED,
440 471
                 lastNEndpoints, endpointsEnteringLastN);
441 472
         });
473
+    conference.xmpp.addListener(XMPPEvents.PASSWORD_REQUIRED, function () {
474
+        conference.eventEmitter.emit(JitsiConferenceErrors.PASSWORD_REQUIRED);
475
+    });
442 476
 
443 477
     if(conference.statistics) {
444 478
         //FIXME: Maybe remove event should not be associated with the conference.

+ 4
- 0
JitsiConferenceErrors.js Ver fichero

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

+ 9
- 0
doc/API.md Ver fichero

@@ -93,6 +93,7 @@ JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.ERROR);
93 93
     1. conference
94 94
         - CONNECTION_ERROR - the connection with the conference is lost.
95 95
         - PASSWORD_REQUIRED - that error can be passed when the connection to the conference failed. You should try to join the conference with password.
96
+        - PASSWORD_NOT_SUPPORTED - indicates that password cannot be set for this conference
96 97
         - VIDEOBRIDGE_NOT_AVAILABLE - video bridge issues.
97 98
     2. connection
98 99
         - 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
225 226
 
226 227
 21. isModerator() - checks if local user has "moderator" role
227 228
 
229
+22. lock(password) - set password for the conference; returns Promise
230
+    - password - string password
231
+
232
+    Note: available only for moderator
233
+
234
+23. unlock() - unset conference password; returns Promise
235
+
236
+    Note: available only for moderator
228 237
 
229 238
 JitsiTrack
230 239
 ======

Loading…
Cancelar
Guardar