You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

actions.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* global APP, config */
  2. import ConferenceUrl from '../../../modules/URL/ConferenceUrl';
  3. import BoshAddressChoice from '../../../modules/config/BoshAddressChoice';
  4. import { obtainConfig, setTokenData } from './functions';
  5. const logger = require('jitsi-meet-logger').getLogger(__filename);
  6. /**
  7. * If we have an HTTP endpoint for getting config.json configured
  8. * we're going to read it and override properties from config.js and
  9. * interfaceConfig.js. If there is no endpoint we'll just
  10. * continue with initialization.
  11. * Keep in mind that if the endpoint has been configured and we fail
  12. * to obtain the config for any reason then the conference won't
  13. * start and error message will be displayed to the user.
  14. *
  15. * @returns {Function}
  16. */
  17. export function obtainConfigAndInit() {
  18. return () => {
  19. const room = APP.conference.roomName;
  20. if (config.configLocation) {
  21. const location = config.configLocation;
  22. obtainConfig(location, room)
  23. .then(_obtainConfigHandler)
  24. .then(_initConference)
  25. .catch(err => {
  26. // Show obtain config error,
  27. // pass the error object for report
  28. APP.UI.messageHandler.openReportDialog(
  29. null, 'dialog.connectError', err);
  30. });
  31. } else {
  32. BoshAddressChoice.chooseAddress(config, room);
  33. _initConference();
  34. }
  35. };
  36. }
  37. /**
  38. * Obtain config handler.
  39. *
  40. * @returns {Promise}
  41. * @private
  42. */
  43. function _obtainConfigHandler() {
  44. const now = window.performance.now();
  45. APP.connectionTimes['configuration.fetched'] = now;
  46. logger.log('(TIME) configuration fetched:\t', now);
  47. return Promise.resolve();
  48. }
  49. /**
  50. * Initialization of the app.
  51. *
  52. * @returns {void}
  53. * @private
  54. */
  55. function _initConference() {
  56. setTokenData();
  57. // Initialize the conference URL handler
  58. APP.ConferenceUrl = new ConferenceUrl(window.location);
  59. }