From 0ec8ab69a048b282817bac3fca1cb7cfbe2ad5d0 Mon Sep 17 00:00:00 2001 From: isymchych Date: Fri, 18 Dec 2015 15:59:38 +0200 Subject: [PATCH] properly update nickname --- app.js | 9 ++++-- lib-jitsi-meet.js | 43 +++++++++++++++++++++++++++- modules/AuthHandler.js | 1 + modules/UI/videolayout/LocalVideo.js | 2 +- 4 files changed, 50 insertions(+), 5 deletions(-) diff --git a/app.js b/app.js index 97bd80b8e..678ee2b4c 100644 --- a/app.js +++ b/app.js @@ -196,7 +196,7 @@ function initConference(localTracks, connection) { room.on(ConferenceEvents.TRACK_ADDED, function (track) { - if (track.isLocal) { // skip local tracks + if (track.isLocal()) { // skip local tracks return; } console.error( @@ -205,7 +205,7 @@ function initConference(localTracks, connection) { APP.UI.addRemoteStream(track); }); room.on(ConferenceEvents.TRACK_REMOVED, function (track) { - if (track.isLocal) { // skip local tracks + if (track.isLocal()) { // skip local tracks return; } @@ -320,7 +320,10 @@ function initConference(localTracks, connection) { nick = APP.UI.askForNickname(); APP.settings.setDisplayName(nick); } - room.setDisplayName(nick); + + if (nick) { + room.setDisplayName(nick); + } room.on(ConferenceEvents.DISPLAY_NAME_CHANGED, function (id, displayName) { APP.UI.changeDisplayName(id, displayName); }); diff --git a/lib-jitsi-meet.js b/lib-jitsi-meet.js index bf382d4bb..be998a197 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"); @@ -213,6 +214,9 @@ JitsiConference.prototype.removeCommand = function (name) { */ JitsiConference.prototype.setDisplayName = function(name) { if(this.room){ + // remove previously set nickname + this.room.removeFromPresence("nick"); + this.room.addToPresence("nick", {attributes: {xmlns: 'http://jabber.org/protocol/nick'}, value: name}); this.room.sendPresence(); } @@ -559,6 +563,10 @@ function setupListeners(conference) { conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.SETUP_FAILED); }); + conference.room.addListener(AuthenticationEvents.IDENTITY_UPDATED, function (authEnabled, authIdentity) { + console.error(authEnabled, 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); @@ -609,7 +617,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}} @@ -959,9 +967,21 @@ var LibJitsiMeet = { return tracks; }); }, + /** + * Checks if its possible to enumerate available cameras/micropones. + * @returns {boolean} true if available, false otherwise. + */ isDeviceListAvailable: function () { return RTC.isDeviceListAvailable(); }, + /** + * Returns true if changing the camera / microphone device is supported and + * false if not. + * @returns {boolean} true if available, false otherwise. + */ + isDeviceChangeAvailable: function () { + return RTC.isDeviceChangeAvailable(); + }, enumerateDevices: function (callback) { RTC.enumerateDevices(callback); } @@ -2046,10 +2066,21 @@ RTC.getVideoSrc = function (element) { return RTCUtils.getVideoSrc(element); }; +/** + * Returns true if retrieving the the list of input devices is supported and + * false if not. + */ RTC.isDeviceListAvailable = function () { return RTCUtils.isDeviceListAvailable(); }; +/** + * Returns true if changing the camera / microphone device is supported and + * false if not. + */ +RTC.isDeviceChangeAvailable = function () { + return RTCUtils.isDeviceChangeAvailable(); +} /** * Allows to receive list of available cameras/microphones. * @param {function} callback would receive array of devices as an argument @@ -3007,6 +3038,16 @@ var RTCUtils = { } return (MediaStreamTrack && MediaStreamTrack.getSources)? true : false; }, + /** + * Returns true if changing the camera / microphone device is supported and + * false if not. + */ + isDeviceChangeAvailable: function () { + if(RTCBrowserType.isChrome() || RTCBrowserType.isOpera() || + RTCBrowserType.isTemasysPluginUsed()) + return true; + return false; + }, /** * A method to handle stopping of the stream. * One point to handle the differences in various implementations. diff --git a/modules/AuthHandler.js b/modules/AuthHandler.js index 3b9bd6c34..20ff7fbd5 100644 --- a/modules/AuthHandler.js +++ b/modules/AuthHandler.js @@ -52,6 +52,7 @@ function doXmppAuth (room, lockPassword) { room.room.moderator.allocateConferenceFocus(function () { connection.disconnect(); loginDialog.close(); + room.join(lockPassword); }); }, function (err) { diff --git a/modules/UI/videolayout/LocalVideo.js b/modules/UI/videolayout/LocalVideo.js index 0dc8f95bf..b23da4845 100644 --- a/modules/UI/videolayout/LocalVideo.js +++ b/modules/UI/videolayout/LocalVideo.js @@ -125,7 +125,7 @@ LocalVideo.prototype.setDisplayName = function(displayName, key) { if (e.keyCode === 13) { e.preventDefault(); $('#editDisplayName').hide(); - self.VideoLayout.inputDisplayNameHandler(this.value); + // focusout handler will save display name } }); });