2017-10-13 19:31:05 +00:00
|
|
|
// @flow
|
2017-01-10 21:55:31 +00:00
|
|
|
|
|
|
|
import ConferenceUrl from '../../../modules/URL/ConferenceUrl';
|
|
|
|
|
2017-12-12 19:16:55 +00:00
|
|
|
import { 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
|
|
|
|
2017-10-13 19:31:05 +00:00
|
|
|
declare var APP: Object;
|
|
|
|
declare var config: Object;
|
|
|
|
|
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() {
|
|
|
|
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}
|
|
|
|
*/
|
2017-10-13 19:31:05 +00:00
|
|
|
function _obtainConfig(location: string, room: string) {
|
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 => {
|
2017-11-03 19:05:03 +00:00
|
|
|
logger.log(err);
|
|
|
|
|
2017-01-10 21:55:31 +00:00
|
|
|
// Show obtain config error.
|
2017-11-03 19:05:03 +00:00
|
|
|
APP.UI.messageHandler.showError({
|
|
|
|
titleKey: 'connection.CONNFAIL',
|
|
|
|
descriptionKey: 'dialog.connectError'
|
|
|
|
});
|
2017-01-10 21:55:31 +00:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
_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);
|
|
|
|
}
|