Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /* global APP, config */
  2. import ConferenceUrl from '../../../modules/URL/ConferenceUrl';
  3. import { chooseBOSHAddress, obtainConfig } from '../base/config';
  4. import { RouteRegistry } from '../base/react';
  5. import { Conference } from './components';
  6. const logger = require('jitsi-meet-logger').getLogger(__filename);
  7. /**
  8. * Register route for Conference (page).
  9. */
  10. RouteRegistry.register({
  11. component: Conference,
  12. onEnter: () => {
  13. // XXX If config or jwt are set by hash or query parameters
  14. // Getting raw URL before stripping it.
  15. _obtainConfigAndInit();
  16. },
  17. path: '/:room'
  18. });
  19. /**
  20. * Initialization of the app.
  21. *
  22. * @private
  23. * @returns {void}
  24. */
  25. function _initConference() {
  26. _setTokenData();
  27. // Initialize the conference URL handler
  28. APP.ConferenceUrl = new ConferenceUrl(window.location);
  29. }
  30. /**
  31. * Promise wrapper on obtain config method. When HttpConfigFetch will be moved
  32. * to React app it's better to use load config instead.
  33. *
  34. * @param {string} location - URL of the domain from which the config is to be
  35. * obtained.
  36. * @param {string} room - Room name.
  37. * @private
  38. * @returns {Promise}
  39. */
  40. function _obtainConfig(location, room) {
  41. return new Promise((resolve, reject) =>
  42. obtainConfig(location, room, (success, error) => {
  43. success ? resolve() : reject(error);
  44. })
  45. );
  46. }
  47. /**
  48. * If we have an HTTP endpoint for getting config.json configured we're going to
  49. * read it and override properties from config.js and interfaceConfig.js. If
  50. * there is no endpoint we'll just continue with initialization. Keep in mind
  51. * that if the endpoint has been configured and we fail to obtain the config for
  52. * any reason then the conference won't start and error message will be
  53. * displayed to the user.
  54. *
  55. * @private
  56. * @returns {void}
  57. */
  58. function _obtainConfigAndInit() {
  59. // Skip initialization if conference is initialized already.
  60. if (typeof APP !== 'undefined' && !APP.ConferenceUrl) {
  61. const location = config.configLocation;
  62. const room = APP.conference.roomName;
  63. if (location) {
  64. _obtainConfig(location, room)
  65. .then(() => {
  66. _obtainConfigHandler();
  67. _initConference();
  68. })
  69. .catch(err => {
  70. // Show obtain config error.
  71. APP.UI.messageHandler.openReportDialog(
  72. null,
  73. 'dialog.connectError',
  74. err);
  75. });
  76. } else {
  77. chooseBOSHAddress(config, room);
  78. _initConference();
  79. }
  80. }
  81. }
  82. /**
  83. * Obtain config handler.
  84. *
  85. * @private
  86. * @returns {Promise}
  87. */
  88. function _obtainConfigHandler() {
  89. const now = window.performance.now();
  90. APP.connectionTimes['configuration.fetched'] = now;
  91. logger.log('(TIME) configuration fetched:\t', now);
  92. }
  93. /**
  94. * If JWT token data it will be used for local user settings.
  95. *
  96. * @private
  97. * @returns {void}
  98. */
  99. function _setTokenData() {
  100. const state = APP.store.getState();
  101. const { caller } = state['features/base/jwt'];
  102. if (caller) {
  103. const { avatarUrl, avatar, email, name } = caller;
  104. APP.settings.setEmail((email || '').trim(), true);
  105. APP.settings.setAvatarUrl((avatarUrl || avatar || '').trim());
  106. APP.settings.setDisplayName((name || '').trim(), true);
  107. }
  108. }