|
|
@@ -1,11 +1,13 @@
|
|
1
|
|
-/* global Strophe, $ */
|
|
|
1
|
+/* global Strophe, $, Promise */
|
|
2
|
2
|
/* jshint -W101 */
|
|
3
|
3
|
var logger = require("jitsi-meet-logger").getLogger(__filename);
|
|
4
|
4
|
var RTC = require("./modules/RTC/RTC");
|
|
5
|
5
|
var XMPPEvents = require("./service/xmpp/XMPPEvents");
|
|
|
6
|
+var AuthenticationEvents = require("./service/authentication/AuthenticationEvents");
|
|
6
|
7
|
var RTCEvents = require("./service/RTC/RTCEvents");
|
|
7
|
8
|
var EventEmitter = require("events");
|
|
8
|
9
|
var JitsiConferenceEvents = require("./JitsiConferenceEvents");
|
|
|
10
|
+var JitsiConferenceErrors = require("./JitsiConferenceErrors");
|
|
9
|
11
|
var JitsiParticipant = require("./JitsiParticipant");
|
|
10
|
12
|
var Statistics = require("./modules/statistics/statistics");
|
|
11
|
13
|
var JitsiDTMFManager = require('./modules/DTMF/JitsiDTMFManager');
|
|
|
@@ -30,7 +32,7 @@ function JitsiConference(options) {
|
|
30
|
32
|
this.connection = this.options.connection;
|
|
31
|
33
|
this.xmpp = this.connection.xmpp;
|
|
32
|
34
|
this.eventEmitter = new EventEmitter();
|
|
33
|
|
- this.room = this.xmpp.createRoom(this.options.name, null, null, this.options.config);
|
|
|
35
|
+ this.room = this.xmpp.createRoom(this.options.name, this.options.config);
|
|
34
|
36
|
this.room.updateDeviceAvailability(RTC.getDeviceAvailability());
|
|
35
|
37
|
this.rtc = new RTC(this.room, options);
|
|
36
|
38
|
if(!RTC.options.disableAudioLevels)
|
|
|
@@ -40,6 +42,8 @@ function JitsiConference(options) {
|
|
40
|
42
|
this.lastActiveSpeaker = null;
|
|
41
|
43
|
this.dtmfManager = null;
|
|
42
|
44
|
this.somebodySupportsDTMF = false;
|
|
|
45
|
+ this.authEnabled = false;
|
|
|
46
|
+ this.authIdentity;
|
|
43
|
47
|
}
|
|
44
|
48
|
|
|
45
|
49
|
/**
|
|
|
@@ -51,6 +55,13 @@ JitsiConference.prototype.join = function (password) {
|
|
51
|
55
|
this.room.join(password, this.connection.tokenPassword);
|
|
52
|
56
|
};
|
|
53
|
57
|
|
|
|
58
|
+/**
|
|
|
59
|
+ * Check if joined to the conference.
|
|
|
60
|
+ */
|
|
|
61
|
+JitsiConference.prototype.isJoined = function () {
|
|
|
62
|
+ return this.room && this.room.joined;
|
|
|
63
|
+};
|
|
|
64
|
+
|
|
54
|
65
|
/**
|
|
55
|
66
|
* Leaves the conference.
|
|
56
|
67
|
*/
|
|
|
@@ -60,6 +71,61 @@ JitsiConference.prototype.leave = function () {
|
|
60
|
71
|
this.room = null;
|
|
61
|
72
|
};
|
|
62
|
73
|
|
|
|
74
|
+/**
|
|
|
75
|
+ * Returns name of this conference.
|
|
|
76
|
+ */
|
|
|
77
|
+JitsiConference.prototype.getName = function () {
|
|
|
78
|
+ return this.options.name;
|
|
|
79
|
+};
|
|
|
80
|
+
|
|
|
81
|
+/**
|
|
|
82
|
+ * Check if authentication is enabled for this conference.
|
|
|
83
|
+ */
|
|
|
84
|
+JitsiConference.prototype.isAuthEnabled = function () {
|
|
|
85
|
+ return this.authEnabled;
|
|
|
86
|
+};
|
|
|
87
|
+
|
|
|
88
|
+/**
|
|
|
89
|
+ * Check if user is logged in.
|
|
|
90
|
+ */
|
|
|
91
|
+JitsiConference.prototype.isLoggedIn = function () {
|
|
|
92
|
+ return !!this.authIdentity;
|
|
|
93
|
+};
|
|
|
94
|
+
|
|
|
95
|
+/**
|
|
|
96
|
+ * Get authorized login.
|
|
|
97
|
+ */
|
|
|
98
|
+JitsiConference.prototype.getAuthLogin = function () {
|
|
|
99
|
+ return this.authIdentity;
|
|
|
100
|
+};
|
|
|
101
|
+
|
|
|
102
|
+/**
|
|
|
103
|
+ * Check if external authentication is enabled for this conference.
|
|
|
104
|
+ */
|
|
|
105
|
+JitsiConference.prototype.isExternalAuthEnabled = function () {
|
|
|
106
|
+ return this.room && this.room.moderator.isExternalAuthEnabled();
|
|
|
107
|
+};
|
|
|
108
|
+
|
|
|
109
|
+/**
|
|
|
110
|
+ * Get url for external authentication.
|
|
|
111
|
+ * @param {boolean} [urlForPopup] if true then return url for login popup,
|
|
|
112
|
+ * else url of login page.
|
|
|
113
|
+ * @returns {Promise}
|
|
|
114
|
+ */
|
|
|
115
|
+JitsiConference.prototype.getExternalAuthUrl = function (urlForPopup) {
|
|
|
116
|
+ return new Promise(function (resolve, reject) {
|
|
|
117
|
+ if (!this.isExternalAuthEnabled()) {
|
|
|
118
|
+ reject();
|
|
|
119
|
+ return;
|
|
|
120
|
+ }
|
|
|
121
|
+ if (urlForPopup) {
|
|
|
122
|
+ this.room.moderator.getPopupLoginUrl(resolve, reject);
|
|
|
123
|
+ } else {
|
|
|
124
|
+ this.room.moderator.getLoginUrl(resolve, reject);
|
|
|
125
|
+ }
|
|
|
126
|
+ }.bind(this));
|
|
|
127
|
+};
|
|
|
128
|
+
|
|
63
|
129
|
/**
|
|
64
|
130
|
* Returns the local tracks.
|
|
65
|
131
|
*/
|
|
|
@@ -225,6 +291,11 @@ JitsiConference.prototype._fireMuteChangeEvent = function (track) {
|
|
225
|
291
|
* @param track the JitsiLocalTrack object.
|
|
226
|
292
|
*/
|
|
227
|
293
|
JitsiConference.prototype.removeTrack = function (track) {
|
|
|
294
|
+ if(!this.room){
|
|
|
295
|
+ if(this.rtc)
|
|
|
296
|
+ this.rtc.removeLocalStream(track);
|
|
|
297
|
+ return;
|
|
|
298
|
+ }
|
|
228
|
299
|
this.room.removeStream(track.getOriginalStream(), function(){
|
|
229
|
300
|
this.rtc.removeLocalStream(track);
|
|
230
|
301
|
this.eventEmitter.emit(JitsiConferenceEvents.TRACK_REMOVED, track);
|
|
|
@@ -247,6 +318,36 @@ JitsiConference.prototype.isModerator = function () {
|
|
247
|
318
|
return this.room.isModerator();
|
|
248
|
319
|
};
|
|
249
|
320
|
|
|
|
321
|
+/**
|
|
|
322
|
+ * Set password for the room.
|
|
|
323
|
+ * @param {string} password new password for the room.
|
|
|
324
|
+ * @returns {Promise}
|
|
|
325
|
+ */
|
|
|
326
|
+JitsiConference.prototype.lock = function (password) {
|
|
|
327
|
+ if (!this.isModerator()) {
|
|
|
328
|
+ return Promise.reject();
|
|
|
329
|
+ }
|
|
|
330
|
+
|
|
|
331
|
+ var conference = this;
|
|
|
332
|
+ return new Promise(function (resolve, reject) {
|
|
|
333
|
+ conference.xmpp.lockRoom(password, function () {
|
|
|
334
|
+ resolve();
|
|
|
335
|
+ }, function (err) {
|
|
|
336
|
+ reject(err);
|
|
|
337
|
+ }, function () {
|
|
|
338
|
+ reject(JitsiConferenceErrors.PASSWORD_NOT_SUPPORTED);
|
|
|
339
|
+ });
|
|
|
340
|
+ });
|
|
|
341
|
+};
|
|
|
342
|
+
|
|
|
343
|
+/**
|
|
|
344
|
+ * Remove password from the room.
|
|
|
345
|
+ * @returns {Promise}
|
|
|
346
|
+ */
|
|
|
347
|
+JitsiConference.prototype.unlock = function () {
|
|
|
348
|
+ return this.lock(undefined);
|
|
|
349
|
+};
|
|
|
350
|
+
|
|
250
|
351
|
/**
|
|
251
|
352
|
* Elects the participant with the given id to be the selected participant or the speaker.
|
|
252
|
353
|
* @param id the identifier of the participant
|
|
|
@@ -288,10 +389,13 @@ JitsiConference.prototype.getParticipantById = function(id) {
|
|
288
|
389
|
|
|
289
|
390
|
JitsiConference.prototype.onMemberJoined = function (jid, email, nick) {
|
|
290
|
391
|
var id = Strophe.getResourceFromJid(jid);
|
|
|
392
|
+ if (id === 'focus') {
|
|
|
393
|
+ return;
|
|
|
394
|
+ }
|
|
291
|
395
|
var participant = new JitsiParticipant(id, this, nick);
|
|
292
|
|
- this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, id);
|
|
293
|
396
|
this.participants[id] = participant;
|
|
294
|
|
- this.connection.xmpp.connection.disco.info(
|
|
|
397
|
+ this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, id, participant);
|
|
|
398
|
+ this.xmpp.connection.disco.info(
|
|
295
|
399
|
jid, "node", function(iq) {
|
|
296
|
400
|
participant._supportsDTMF = $(iq).find(
|
|
297
|
401
|
'>query>feature[var="urn:xmpp:jingle:dtmf:0"]').length > 0;
|
|
|
@@ -302,8 +406,12 @@ JitsiConference.prototype.onMemberJoined = function (jid, email, nick) {
|
|
302
|
406
|
|
|
303
|
407
|
JitsiConference.prototype.onMemberLeft = function (jid) {
|
|
304
|
408
|
var id = Strophe.getResourceFromJid(jid);
|
|
|
409
|
+ if (id === 'focus') {
|
|
|
410
|
+ return;
|
|
|
411
|
+ }
|
|
|
412
|
+ var participant = this.participants[id];
|
|
305
|
413
|
delete this.participants[id];
|
|
306
|
|
- this.eventEmitter.emit(JitsiConferenceEvents.USER_LEFT, id);
|
|
|
414
|
+ this.eventEmitter.emit(JitsiConferenceEvents.USER_LEFT, id, participant);
|
|
307
|
415
|
};
|
|
308
|
416
|
|
|
309
|
417
|
JitsiConference.prototype.onUserRoleChanged = function (jid, role) {
|
|
|
@@ -399,7 +507,7 @@ JitsiConference.prototype.myUserId = function () {
|
|
399
|
507
|
|
|
400
|
508
|
JitsiConference.prototype.sendTones = function (tones, duration, pause) {
|
|
401
|
509
|
if (!this.dtmfManager) {
|
|
402
|
|
- var connection = this.connection.xmpp.connection.jingle.activecall.peerconnection;
|
|
|
510
|
+ var connection = this.xmpp.connection.jingle.activecall.peerconnection;
|
|
403
|
511
|
if (!connection) {
|
|
404
|
512
|
logger.warn("cannot sendTones: no conneciton");
|
|
405
|
513
|
return;
|
|
|
@@ -418,94 +526,6 @@ JitsiConference.prototype.sendTones = function (tones, duration, pause) {
|
|
418
|
526
|
this.dtmfManager.sendTones(tones, duration, pause);
|
|
419
|
527
|
};
|
|
420
|
528
|
|
|
421
|
|
-/**
|
|
422
|
|
- * Returns true if the recording is supproted and false if not.
|
|
423
|
|
- */
|
|
424
|
|
-JitsiConference.prototype.isRecordingSupported = function () {
|
|
425
|
|
- if(this.room)
|
|
426
|
|
- return this.room.isRecordingSupported();
|
|
427
|
|
- return false;
|
|
428
|
|
-};
|
|
429
|
|
-
|
|
430
|
|
-/**
|
|
431
|
|
- * Returns null if the recording is not supported, "on" if the recording started
|
|
432
|
|
- * and "off" if the recording is not started.
|
|
433
|
|
- */
|
|
434
|
|
-JitsiConference.prototype.getRecordingState = function () {
|
|
435
|
|
- if(this.room)
|
|
436
|
|
- return this.room.getRecordingState();
|
|
437
|
|
- return "off";
|
|
438
|
|
-}
|
|
439
|
|
-
|
|
440
|
|
-/**
|
|
441
|
|
- * Returns the url of the recorded video.
|
|
442
|
|
- */
|
|
443
|
|
-JitsiConference.prototype.getRecordingURL = function () {
|
|
444
|
|
- if(this.room)
|
|
445
|
|
- return this.room.getRecordingURL();
|
|
446
|
|
- return null;
|
|
447
|
|
-}
|
|
448
|
|
-
|
|
449
|
|
-/**
|
|
450
|
|
- * Starts/stops the recording
|
|
451
|
|
- * @param token a token for authentication.
|
|
452
|
|
- */
|
|
453
|
|
-JitsiConference.prototype.toggleRecording = function (token, followEntity) {
|
|
454
|
|
- if(this.room)
|
|
455
|
|
- return this.room.toggleRecording(token, followEntity);
|
|
456
|
|
- return new Promise(function(resolve, reject){
|
|
457
|
|
- reject(new Error("The conference is not created yet!"))});
|
|
458
|
|
-}
|
|
459
|
|
-
|
|
460
|
|
-/**
|
|
461
|
|
- * Dials a number.
|
|
462
|
|
- * @param number the number
|
|
463
|
|
- */
|
|
464
|
|
-JitsiConference.prototype.dial = function (number) {
|
|
465
|
|
- if(this.room)
|
|
466
|
|
- return this.room.dial(number);
|
|
467
|
|
- return new Promise(function(resolve, reject){
|
|
468
|
|
- reject(new Error("The conference is not created yet!"))});
|
|
469
|
|
-}
|
|
470
|
|
-
|
|
471
|
|
-/**
|
|
472
|
|
- * Hangup an existing call
|
|
473
|
|
- */
|
|
474
|
|
-JitsiConference.prototype.hangup = function () {
|
|
475
|
|
- if(this.room)
|
|
476
|
|
- return this.room.hangup();
|
|
477
|
|
- return new Promise(function(resolve, reject){
|
|
478
|
|
- reject(new Error("The conference is not created yet!"))});
|
|
479
|
|
-}
|
|
480
|
|
-
|
|
481
|
|
-/**
|
|
482
|
|
- * Returns the phone number for joining the conference.
|
|
483
|
|
- */
|
|
484
|
|
-JitsiConference.prototype.getPhoneNumber = function () {
|
|
485
|
|
- if(this.room)
|
|
486
|
|
- return this.room.getPhoneNumber();
|
|
487
|
|
- return null;
|
|
488
|
|
-}
|
|
489
|
|
-
|
|
490
|
|
-/**
|
|
491
|
|
- * Returns the pin for joining the conference with phone.
|
|
492
|
|
- */
|
|
493
|
|
-JitsiConference.prototype.getPhonePin = function () {
|
|
494
|
|
- if(this.room)
|
|
495
|
|
- return this.room.getPhonePin();
|
|
496
|
|
- return null;
|
|
497
|
|
-}
|
|
498
|
|
-
|
|
499
|
|
-/**
|
|
500
|
|
- * Returns the connection state for the current room. Its ice connection state
|
|
501
|
|
- * for its session.
|
|
502
|
|
- */
|
|
503
|
|
-JitsiConference.prototype.getConnectionState = function () {
|
|
504
|
|
- if(this.room)
|
|
505
|
|
- return this.room.getConnectionState();
|
|
506
|
|
- return null;
|
|
507
|
|
-}
|
|
508
|
|
-
|
|
509
|
529
|
/**
|
|
510
|
530
|
* Setups the listeners needed for the conference.
|
|
511
|
531
|
* @param conference the conference
|
|
|
@@ -529,6 +549,18 @@ function setupListeners(conference) {
|
|
529
|
549
|
conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
|
|
530
|
550
|
conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_JOINED);
|
|
531
|
551
|
});
|
|
|
552
|
+ conference.room.addListener(XMPPEvents.ROOM_JOIN_ERROR, function (pres) {
|
|
|
553
|
+ conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.CONNECTION_ERROR, pres);
|
|
|
554
|
+ });
|
|
|
555
|
+ conference.room.addListener(XMPPEvents.ROOM_CONNECT_ERROR, function (pres) {
|
|
|
556
|
+ conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.CONNECTION_ERROR, pres);
|
|
|
557
|
+ });
|
|
|
558
|
+ conference.room.addListener(XMPPEvents.PASSWORD_REQUIRED, function (pres) {
|
|
|
559
|
+ conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.PASSWORD_REQUIRED, pres);
|
|
|
560
|
+ });
|
|
|
561
|
+ conference.room.addListener(XMPPEvents.AUTHENTICATION_REQUIRED, function () {
|
|
|
562
|
+ conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.AUTHENTICATION_REQUIRED);
|
|
|
563
|
+ });
|
|
532
|
564
|
// FIXME
|
|
533
|
565
|
// conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
|
|
534
|
566
|
// conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_LEFT);
|
|
|
@@ -548,22 +580,21 @@ function setupListeners(conference) {
|
|
548
|
580
|
conference.eventEmitter.emit(JitsiConferenceEvents.CONNECTION_INTERRUPTED);
|
|
549
|
581
|
});
|
|
550
|
582
|
|
|
551
|
|
- conference.room.addListener(XMPPEvents.RECORDING_STATE_CHANGED,
|
|
552
|
|
- function () {
|
|
553
|
|
- conference.eventEmitter.emit(
|
|
554
|
|
- JitsiConferenceEvents.RECORDING_STATE_CHANGED);
|
|
555
|
|
- });
|
|
556
|
|
-
|
|
557
|
|
- conference.room.addListener(XMPPEvents.PHONE_NUMBER_CHANGED, function () {
|
|
558
|
|
- conference.eventEmitter.emit(
|
|
559
|
|
- JitsiConferenceEvents.PHONE_NUMBER_CHANGED);
|
|
560
|
|
- });
|
|
561
|
|
-
|
|
562
|
583
|
conference.room.addListener(XMPPEvents.CONNECTION_RESTORED, function () {
|
|
563
|
584
|
conference.eventEmitter.emit(JitsiConferenceEvents.CONNECTION_RESTORED);
|
|
564
|
585
|
});
|
|
565
|
586
|
conference.room.addListener(XMPPEvents.CONFERENCE_SETUP_FAILED, function () {
|
|
566
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.SETUP_FAILED);
|
|
|
587
|
+ conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.SETUP_FAILED);
|
|
|
588
|
+ });
|
|
|
589
|
+
|
|
|
590
|
+ conference.room.addListener(AuthenticationEvents.IDENTITY_UPDATED, function (authEnabled, authIdentity) {
|
|
|
591
|
+ conference.authEnabled = authEnabled;
|
|
|
592
|
+ conference.authIdentity = authIdentity;
|
|
|
593
|
+ });
|
|
|
594
|
+
|
|
|
595
|
+ conference.room.addListener(XMPPEvents.MESSAGE_RECEIVED, function (jid, displayName, txt, myJid, ts) {
|
|
|
596
|
+ var id = Strophe.getResourceFromJid(jid);
|
|
|
597
|
+ conference.eventEmitter.emit(JitsiConferenceEvents.MESSAGE_RECEIVED, id, txt, ts);
|
|
567
|
598
|
});
|
|
568
|
599
|
|
|
569
|
600
|
conference.rtc.addListener(RTCEvents.DOMINANTSPEAKER_CHANGED, function (id) {
|
|
|
@@ -582,6 +613,9 @@ function setupListeners(conference) {
|
|
582
|
613
|
conference.eventEmitter.emit(JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED,
|
|
583
|
614
|
lastNEndpoints, endpointsEnteringLastN);
|
|
584
|
615
|
});
|
|
|
616
|
+ conference.xmpp.addListener(XMPPEvents.PASSWORD_REQUIRED, function () {
|
|
|
617
|
+ conference.eventEmitter.emit(JitsiConferenceErrors.PASSWORD_REQUIRED);
|
|
|
618
|
+ });
|
|
585
|
619
|
|
|
586
|
620
|
if(conference.statistics) {
|
|
587
|
621
|
//FIXME: Maybe remove event should not be associated with the conference.
|