2017-01-10 21:55:31 +00:00
|
|
|
/* global APP, config */
|
|
|
|
|
|
|
|
import ConferenceUrl from '../../../modules/URL/ConferenceUrl';
|
|
|
|
|
2017-05-04 15:20:41 +00:00
|
|
|
import { chooseBOSHAddress, obtainConfig } from '../base/config';
|
2017-01-29 01:56:35 +00:00
|
|
|
import { RouteRegistry } from '../base/react';
|
2017-01-13 22:37:53 +00:00
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
import { Conference } from './components';
|
2017-01-10 21:55:31 +00:00
|
|
|
|
|
|
|
const logger = require('jitsi-meet-logger').getLogger(__filename);
|
2016-10-05 14:36:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Register route for Conference (page).
|
|
|
|
*/
|
|
|
|
RouteRegistry.register({
|
|
|
|
component: Conference,
|
2017-01-04 17:01:25 +00:00
|
|
|
onEnter: () => {
|
2017-01-10 21:55:31 +00:00
|
|
|
// XXX If config or jwt are set by hash or query parameters
|
2017-01-04 17:01:25 +00:00
|
|
|
// Getting raw URL before stripping it.
|
2017-01-10 21:55:31 +00:00
|
|
|
_obtainConfigAndInit();
|
2017-01-10 19:06:18 +00:00
|
|
|
},
|
|
|
|
path: '/:room'
|
2016-10-05 14:36:59 +00:00
|
|
|
});
|
2017-01-10 21:55:31 +00:00
|
|
|
|
|
|
|
/**
|
2017-05-31 05:24:34 +00:00
|
|
|
* Initialization of the app.
|
2017-01-10 21:55:31 +00:00
|
|
|
*
|
2017-05-31 05:24:34 +00:00
|
|
|
* @private
|
|
|
|
* @returns {void}
|
2017-01-10 21:55:31 +00:00
|
|
|
*/
|
|
|
|
function _initConference() {
|
|
|
|
_setTokenData();
|
|
|
|
|
|
|
|
// Initialize the conference URL handler
|
|
|
|
APP.ConferenceUrl = new ConferenceUrl(window.location);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Promise wrapper on obtain config method. When HttpConfigFetch will be moved
|
|
|
|
* to React app it's better to use load config instead.
|
|
|
|
*
|
2017-02-01 04:25:09 +00:00
|
|
|
* @param {string} location - URL of the domain from which the config is to be
|
|
|
|
* obtained.
|
2017-01-10 21:55:31 +00:00
|
|
|
* @param {string} room - Room name.
|
|
|
|
* @private
|
|
|
|
* @returns {Promise}
|
|
|
|
*/
|
|
|
|
function _obtainConfig(location, room) {
|
2017-05-04 15:20:41 +00:00
|
|
|
return new Promise((resolve, reject) =>
|
|
|
|
obtainConfig(location, room, (success, error) => {
|
|
|
|
success ? resolve() : reject(error);
|
|
|
|
})
|
|
|
|
);
|
2017-01-10 21:55:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If we have an HTTP endpoint for getting config.json configured we're going to
|
|
|
|
* read it and override properties from config.js and interfaceConfig.js. If
|
|
|
|
* there is no endpoint we'll just continue with initialization. Keep in mind
|
|
|
|
* that if the endpoint has been configured and we fail to obtain the config for
|
|
|
|
* any reason then the conference won't start and error message will be
|
|
|
|
* displayed to the user.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
function _obtainConfigAndInit() {
|
|
|
|
// Skip initialization if conference is initialized already.
|
|
|
|
if (typeof APP !== 'undefined' && !APP.ConferenceUrl) {
|
|
|
|
const location = config.configLocation;
|
|
|
|
const room = APP.conference.roomName;
|
|
|
|
|
|
|
|
if (location) {
|
|
|
|
_obtainConfig(location, room)
|
|
|
|
.then(() => {
|
|
|
|
_obtainConfigHandler();
|
|
|
|
_initConference();
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
// Show obtain config error.
|
|
|
|
APP.UI.messageHandler.openReportDialog(
|
2017-05-31 05:24:34 +00:00
|
|
|
null,
|
|
|
|
'dialog.connectError',
|
|
|
|
err);
|
2017-01-10 21:55:31 +00:00
|
|
|
});
|
|
|
|
} else {
|
2017-05-04 15:20:41 +00:00
|
|
|
chooseBOSHAddress(config, room);
|
2017-01-10 21:55:31 +00:00
|
|
|
_initConference();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Obtain config handler.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {Promise}
|
|
|
|
*/
|
|
|
|
function _obtainConfigHandler() {
|
|
|
|
const now = window.performance.now();
|
|
|
|
|
|
|
|
APP.connectionTimes['configuration.fetched'] = now;
|
|
|
|
logger.log('(TIME) configuration fetched:\t', now);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If JWT token data it will be used for local user settings.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
function _setTokenData() {
|
2017-04-21 10:00:50 +00:00
|
|
|
const state = APP.store.getState();
|
|
|
|
const { caller } = state['features/jwt'];
|
2017-01-10 21:55:31 +00:00
|
|
|
|
2017-04-21 10:00:50 +00:00
|
|
|
if (caller) {
|
2017-07-13 19:45:55 +00:00
|
|
|
const { avatarUrl, avatar, email, name } = caller;
|
2017-01-10 21:55:31 +00:00
|
|
|
|
|
|
|
APP.settings.setEmail((email || '').trim(), true);
|
2017-07-13 19:45:55 +00:00
|
|
|
APP.settings.setAvatarUrl((avatarUrl || avatar || '').trim());
|
2017-01-10 21:55:31 +00:00
|
|
|
APP.settings.setDisplayName((name || '').trim(), true);
|
|
|
|
}
|
|
|
|
}
|