diff --git a/JitsiConference.js b/JitsiConference.js index c57d404ab..d4a82dea7 100644 --- a/JitsiConference.js +++ b/JitsiConference.js @@ -3,6 +3,7 @@ var logger = require("jitsi-meet-logger").getLogger(__filename); var RTC = require("./modules/RTC/RTC"); var XMPPEvents = require("./service/xmpp/XMPPEvents"); +var AuthenticationEvents = require("./service/authentication/AuthenticationEvents"); var RTCEvents = require("./service/RTC/RTCEvents"); var EventEmitter = require("events"); var JitsiConferenceEvents = require("./JitsiConferenceEvents"); @@ -31,7 +32,7 @@ function JitsiConference(options) { this.connection = this.options.connection; this.xmpp = this.connection.xmpp; this.eventEmitter = new EventEmitter(); - this.room = this.xmpp.createRoom(this.options.name, null, null, this.options.config); + this.room = this.xmpp.createRoom(this.options.name, this.options.config); this.room.updateDeviceAvailability(RTC.getDeviceAvailability()); this.rtc = new RTC(this.room, options); if(!RTC.options.disableAudioLevels) @@ -41,6 +42,8 @@ function JitsiConference(options) { this.lastActiveSpeaker = null; this.dtmfManager = null; this.somebodySupportsDTMF = false; + this.authEnabled = false; + this.authIdentity; } /** @@ -75,6 +78,27 @@ JitsiConference.prototype.getName = function () { return this.options.name; }; +/** + * Check if authentication is enabled for this conference. + */ +JitsiConference.prototype.isAuthEnabled = function () { + return this.authEnabled; +}; + +/** + * Check if user is logged in. + */ +JitsiConference.prototype.isLoggedIn = function () { + return !!this.authIdentity; +}; + +/** + * Get authorized login. + */ +JitsiConference.prototype.getAuthLogin = function () { + return this.authIdentity; +}; + /** * Check if external authentication is enabled for this conference. */ @@ -382,6 +406,9 @@ JitsiConference.prototype.onMemberJoined = function (jid, email, nick) { JitsiConference.prototype.onMemberLeft = function (jid) { var id = Strophe.getResourceFromJid(jid); + if (id === 'focus') { + return; + } var participant = this.participants[id]; delete this.participants[id]; this.eventEmitter.emit(JitsiConferenceEvents.USER_LEFT, id, participant); @@ -560,6 +587,11 @@ function setupListeners(conference) { conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.SETUP_FAILED); }); + conference.room.addListener(AuthenticationEvents.IDENTITY_UPDATED, function (authEnabled, authIdentity) { + conference.authEnabled = authEnabled; + conference.authIdentity = authIdentity; + }); + conference.room.addListener(XMPPEvents.MESSAGE_RECEIVED, function (jid, displayName, txt, myJid, ts) { var id = Strophe.getResourceFromJid(jid); conference.eventEmitter.emit(JitsiConferenceEvents.MESSAGE_RECEIVED, id, txt, ts); diff --git a/lib-jitsi-meet.js b/lib-jitsi-meet.js index 79038348f..363d05f47 100644 --- a/lib-jitsi-meet.js +++ b/lib-jitsi-meet.js @@ -5,6 +5,7 @@ var logger = require("jitsi-meet-logger").getLogger(__filename); var RTC = require("./modules/RTC/RTC"); var XMPPEvents = require("./service/xmpp/XMPPEvents"); +var AuthenticationEvents = require("./service/authentication/AuthenticationEvents"); var RTCEvents = require("./service/RTC/RTCEvents"); var EventEmitter = require("events"); var JitsiConferenceEvents = require("./JitsiConferenceEvents"); @@ -33,7 +34,7 @@ function JitsiConference(options) { this.connection = this.options.connection; this.xmpp = this.connection.xmpp; this.eventEmitter = new EventEmitter(); - this.room = this.xmpp.createRoom(this.options.name, null, null, this.options.config); + this.room = this.xmpp.createRoom(this.options.name, this.options.config); this.room.updateDeviceAvailability(RTC.getDeviceAvailability()); this.rtc = new RTC(this.room, options); if(!RTC.options.disableAudioLevels) @@ -43,6 +44,8 @@ function JitsiConference(options) { this.lastActiveSpeaker = null; this.dtmfManager = null; this.somebodySupportsDTMF = false; + this.authEnabled = false; + this.authIdentity; } /** @@ -77,6 +80,27 @@ JitsiConference.prototype.getName = function () { return this.options.name; }; +/** + * Check if authentication is enabled for this conference. + */ +JitsiConference.prototype.isAuthEnabled = function () { + return this.authEnabled; +}; + +/** + * Check if user is logged in. + */ +JitsiConference.prototype.isLoggedIn = function () { + return !!this.authIdentity; +}; + +/** + * Get authorized login. + */ +JitsiConference.prototype.getAuthLogin = function () { + return this.authIdentity; +}; + /** * Check if external authentication is enabled for this conference. */ @@ -384,6 +408,9 @@ JitsiConference.prototype.onMemberJoined = function (jid, email, nick) { JitsiConference.prototype.onMemberLeft = function (jid) { var id = Strophe.getResourceFromJid(jid); + if (id === 'focus') { + return; + } var participant = this.participants[id]; delete this.participants[id]; this.eventEmitter.emit(JitsiConferenceEvents.USER_LEFT, id, participant); @@ -562,6 +589,11 @@ function setupListeners(conference) { conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.SETUP_FAILED); }); + conference.room.addListener(AuthenticationEvents.IDENTITY_UPDATED, function (authEnabled, authIdentity) { + conference.authEnabled = authEnabled; + conference.authIdentity = authIdentity; + }); + conference.room.addListener(XMPPEvents.MESSAGE_RECEIVED, function (jid, displayName, txt, myJid, ts) { var id = Strophe.getResourceFromJid(jid); conference.eventEmitter.emit(JitsiConferenceEvents.MESSAGE_RECEIVED, id, txt, ts); @@ -612,7 +644,7 @@ function setupListeners(conference) { module.exports = JitsiConference; }).call(this,"/JitsiConference.js") -},{"./JitsiConferenceErrors":2,"./JitsiConferenceEvents":3,"./JitsiParticipant":8,"./JitsiTrackEvents":10,"./modules/DTMF/JitsiDTMFManager":11,"./modules/RTC/RTC":16,"./modules/statistics/statistics":24,"./service/RTC/RTCEvents":79,"./service/xmpp/XMPPEvents":85,"events":43,"jitsi-meet-logger":47}],2:[function(require,module,exports){ +},{"./JitsiConferenceErrors":2,"./JitsiConferenceEvents":3,"./JitsiParticipant":8,"./JitsiTrackEvents":10,"./modules/DTMF/JitsiDTMFManager":11,"./modules/RTC/RTC":16,"./modules/statistics/statistics":24,"./service/RTC/RTCEvents":79,"./service/authentication/AuthenticationEvents":81,"./service/xmpp/XMPPEvents":85,"events":43,"jitsi-meet-logger":47}],2:[function(require,module,exports){ /** * Enumeration with the errors for the conference. * @type {{string: string}} @@ -11517,12 +11549,12 @@ XMPP.prototype.connect = function (jid, password) { return this._connect(jid, password); }; -XMPP.prototype.createRoom = function (roomName, options, useNicks, nick) { +XMPP.prototype.createRoom = function (roomName, options) { var roomjid = roomName + '@' + this.options.hosts.muc; - if (useNicks) { - if (nick) { - roomjid += '/' + nick; + if (options.useNicks) { + if (options.nick) { + roomjid += '/' + options.nick; } else { roomjid += '/' + Strophe.getNodeFromJid(this.connection.jid); } diff --git a/modules/xmpp/xmpp.js b/modules/xmpp/xmpp.js index 5fd5fbedf..ec1409c6b 100644 --- a/modules/xmpp/xmpp.js +++ b/modules/xmpp/xmpp.js @@ -180,12 +180,12 @@ XMPP.prototype.connect = function (jid, password) { return this._connect(jid, password); }; -XMPP.prototype.createRoom = function (roomName, options, useNicks, nick) { +XMPP.prototype.createRoom = function (roomName, options) { var roomjid = roomName + '@' + this.options.hosts.muc; - if (useNicks) { - if (nick) { - roomjid += '/' + nick; + if (options.useNicks) { + if (options.nick) { + roomjid += '/' + options.nick; } else { roomjid += '/' + Strophe.getNodeFromJid(this.connection.jid); }