Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

properly generate room name

isymchych586988f32700
diff --git a/app.js b/app.js
index 1201d1700e..65137d24d1 100644
--- a/app.js
+++ b/app.js
@@ -2,49 +2,84 @@
/* application specific logic */
import "babel-polyfill";
-require("jquery");
-require("jquery-ui");
-require("strophe");
-require("strophe-disco");
-require("strophe-caps");
-require("tooltip");
-require("popover");
+import "jquery";
+import "jquery-ui";
+import "strophe";
+import "strophe-disco";
+import "strophe-caps";
+import "tooltip";
+import "popover";
+import "jQuery-Impromptu";
+import "autosize";
window.toastr = require("toastr");
-require("jQuery-Impromptu");
-require("autosize");
-var CQEvents = require('./service/connectionquality/CQEvents');
-var UIEvents = require('./service/UI/UIEvents');
+import RoomnameGenerator from './modules/util/RoomnameGenerator';
+import CQEvents from './service/connectionquality/CQEvents';
+import UIEvents from './service/UI/UIEvents';
-var Commands = {
+const Commands = {
CONNECTION_QUALITY: "connectionQuality",
EMAIL: "email"
};
-var APP = {
- init: function () {
+function buildRoomName () {
+ let path = window.location.pathname;
+ let roomName;
+
+ // determinde the room node from the url
+ // TODO: just the roomnode or the whole bare jid?
+ if (config.getroomnode && typeof config.getroomnode === 'function') {
+ // custom function might be responsible for doing the pushstate
+ roomName = config.getroomnode(path);
+ } else {
+ /* fall back to default strategy
+ * this is making assumptions about how the URL->room mapping happens.
+ * It currently assumes deployment at root, with a rewrite like the
+ * following one (for nginx):
+ location ~ ^/([a-zA-Z0-9]+)$ {
+ rewrite ^/(.*)$ / break;
+ }
+ */
+ if (path.length > 1) {
+ roomName = path.substr(1).toLowerCase();
+ } else {
+ let word = RoomnameGenerator.generateRoomWithoutSeparator();
+ roomName = word.toLowerCase();
+ window.history.pushState(
+ 'VideoChat', 'Room: ' + word, window.location.pathname + word
+ );
+ }
+ }
+
+ return roomName;
+}
+
+const APP = {
+ init () {
JitsiMeetJS.init();
JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.TRACE);
+ let roomName = buildRoomName();
this.conference = {
+ roomName,
localId: undefined,
isModerator: false,
membersCount: 0,
audioMuted: false,
videoMuted: false,
- isLocalId: function (id) {
+ isLocalId (id) {
return this.localId === id;
},
- muteAudio: function (mute) {
+ muteAudio (mute) {
APP.UI.eventEmitter.emit(UIEvents.AUDIO_MUTED, mute);
},
- toggleAudioMuted: function () {
+ toggleAudioMuted () {
this.muteAudio(!this.audioMuted);
},
- muteVideo: function (mute) {
+ muteVideo (mute) {
APP.UI.eventEmitter.emit(UIEvents.VIDEO_MUTED, mute);
},
- toggleVideoMuted: function () {
+ toggleVideoMuted () {
this.muteVideo(!this.videoMuted);
}
};
@@ -315,7 +350,7 @@ function initConference(connection, roomName) {
function init() {
connect().then(function (connection) {
- return initConference(connection, APP.UI.generateRoomName());
+ return initConference(connection, APP.conference.roomName);
}).then(function () {
APP.UI.start();
@@ -342,7 +377,7 @@ function init() {
* will be displayed to the user.
*/
function obtainConfigAndInit() {
- var roomName = APP.UI.getRoomNode();
+ let roomName = APP.conference.roomName;
if (config.configLocation) {
APP.configFetch.obtainConfig(
diff --git a/modules/UI/UI.js b/modules/UI/UI.js
index e95bf22256..fd30f293b7 100644
--- a/modules/UI/UI.js
+++ b/modules/UI/UI.js
@@ -16,7 +16,6 @@ var EventEmitter = require("events");
var SettingsMenu = require("./side_pannels/settings/SettingsMenu");
var Settings = require("./../settings/Settings");
var PanelToggler = require("./side_pannels/SidePanelToggler");
-var RoomnameGenerator = require("../util/RoomnameGenerator");
UI.messageHandler = require("./util/MessageHandler");
var messageHandler = UI.messageHandler;
var Authentication = require("./authentication/Authentication");
@@ -31,9 +30,6 @@ var Feedback = require("./Feedback");
var eventEmitter = new EventEmitter();
UI.eventEmitter = eventEmitter;
-var roomNode = null;
-var roomName = null;
-
function promptDisplayName() {
var message = '<h2 data-i18n="dialog.displayNameRequired">';
@@ -438,7 +434,7 @@ function onMucRoleChanged(role, displayName) {
UI.notifyAuthRequired = function (intervalCallback) {
Authentication.openAuthenticationDialog(
- roomName, intervalCallback, function () {
+ APP.conference.roomName, intervalCallback, function () {
Toolbar.authenticateClicked();
}
);
@@ -478,46 +474,6 @@ UI.getRemoteVideoType = function (jid) {
return VideoLayout.getRemoteVideoType(jid);
};
-UI.getRoomNode = function () {
- if (roomNode)
- return roomNode;
- var path = window.location.pathname;
-
- // determinde the room node from the url
- // TODO: just the roomnode or the whole bare jid?
- if (config.getroomnode && typeof config.getroomnode === 'function') {
- // custom function might be responsible for doing the pushstate
- roomNode = config.getroomnode(path);
- } else {
- /* fall back to default strategy
- * this is making assumptions about how the URL->room mapping happens.
- * It currently assumes deployment at root, with a rewrite like the
- * following one (for nginx):
- location ~ ^/([a-zA-Z0-9]+)$ {
- rewrite ^/(.*)$ / break;
- }
- */
- if (path.length > 1) {
- roomNode = path.substr(1).toLowerCase();
- } else {
- var word = RoomnameGenerator.generateRoomWithoutSeparator();
- roomNode = word.toLowerCase();
- window.history.pushState('VideoChat',
- 'Room: ' + word, window.location.pathname + word);
- }
- }
- return roomNode;
-};
-
-UI.generateRoomName = function () {
- if (roomName)
- return roomName;
- var roomNode = UI.getRoomNode();
- roomName = roomNode + '@' + config.hosts.muc;
- return roomName;
-};
-
-
UI.connectionIndicatorShowMore = function(jid) {
return VideoLayout.showMore(jid);
};
@@ -557,10 +513,6 @@ UI.askForNickname = function () {
return window.prompt('Your nickname (optional)');
};
-UI.getRoomName = function () {
- return roomName;
-};
-
/**
* Sets muted audio state for the local participant.
*/
diff --git a/modules/UI/authentication/Authentication.js b/modules/UI/authentication/Authentication.js
index a3995986f6..4531eb56a9 100644
--- a/modules/UI/authentication/Authentication.js
+++ b/modules/UI/authentication/Authentication.js
@@ -75,7 +75,7 @@ var Authentication = {
// the request.
connection.disconnect();
- var roomName = APP.UI.generateRoomName();
+ var roomName = APP.conference.roomName;
Moderator.allocateConferenceFocus(roomName, function () {
// If it's not "on the fly" authentication now join
// the conference room
diff --git a/modules/UI/authentication/LoginDialog.js b/modules/UI/authentication/LoginDialog.js
index dd52602e3a..cf39bfe314 100644
--- a/modules/UI/authentication/LoginDialog.js
+++ b/modules/UI/authentication/LoginDialog.js
@@ -135,7 +135,7 @@ function Dialog(callback, obtainSession) {
'connection.FETCH_SESSION_ID'));
// Authenticate with Jicofo and obtain session-id
- var roomName = APP.UI.generateRoomName();
+ var roomName = APP.conference.roomName;
// Jicofo will return new session-id when connected
// from authenticated domain
diff --git a/modules/UI/toolbars/Toolbar.js b/modules/UI/toolbars/Toolbar.js
index 0838f67bc8..9746f5e890 100644
--- a/modules/UI/toolbars/Toolbar.js
+++ b/modules/UI/toolbars/Toolbar.js
@@ -301,7 +301,7 @@ function callSipButtonClicked() {
var numberInput = f.sipNumber;
if (numberInput) {
APP.xmpp.dial(
- numberInput, 'fromnumber', APP.UI.getRoomName(), sharedKey);
+ numberInput, 'fromnumber', APP.conference.roomName, sharedKey);
}
}
},
@@ -355,18 +355,18 @@ var Toolbar = (function (my) {
}
// Get authentication URL
if (!APP.xmpp.isMUCJoined()) {
- APP.xmpp.getLoginUrl(APP.UI.getRoomName(), function (url) {
+ APP.xmpp.getLoginUrl(APP.conference.roomName, function (url) {
// If conference has not been started yet - redirect to login page
window.location.href = url;
});
} else {
- APP.xmpp.getPopupLoginUrl(APP.UI.getRoomName(), function (url) {
+ APP.xmpp.getPopupLoginUrl(APP.conference.roomName, function (url) {
// Otherwise - open popup with authentication URL
var authenticationWindow = Authentication.createAuthenticationWindow(
function () {
// On popup closed - retry room allocation
APP.xmpp.allocateConferenceFocus(
- APP.UI.getRoomName(),
+ APP.conference.roomName,
function () { console.info("AUTH DONE"); }
);
}, url);