您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

route.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. // Initialize the conference URL handler
  27. APP.ConferenceUrl = new ConferenceUrl(window.location);
  28. }
  29. /**
  30. * Promise wrapper on obtain config method. When HttpConfigFetch will be moved
  31. * to React app it's better to use load config instead.
  32. *
  33. * @param {string} location - URL of the domain from which the config is to be
  34. * obtained.
  35. * @param {string} room - Room name.
  36. * @private
  37. * @returns {Promise}
  38. */
  39. function _obtainConfig(location, room) {
  40. return new Promise((resolve, reject) =>
  41. obtainConfig(location, room, (success, error) => {
  42. success ? resolve() : reject(error);
  43. })
  44. );
  45. }
  46. /**
  47. * If we have an HTTP endpoint for getting config.json configured we're going to
  48. * read it and override properties from config.js and interfaceConfig.js. If
  49. * there is no endpoint we'll just continue with initialization. Keep in mind
  50. * that if the endpoint has been configured and we fail to obtain the config for
  51. * any reason then the conference won't start and error message will be
  52. * displayed to the user.
  53. *
  54. * @private
  55. * @returns {void}
  56. */
  57. function _obtainConfigAndInit() {
  58. // Skip initialization if conference is initialized already.
  59. if (typeof APP !== 'undefined' && !APP.ConferenceUrl) {
  60. const location = config.configLocation;
  61. const room = APP.conference.roomName;
  62. if (location) {
  63. _obtainConfig(location, room)
  64. .then(() => {
  65. _obtainConfigHandler();
  66. _initConference();
  67. })
  68. .catch(err => {
  69. // Show obtain config error.
  70. APP.UI.messageHandler.openReportDialog(
  71. null,
  72. 'dialog.connectError',
  73. err);
  74. });
  75. } else {
  76. chooseBOSHAddress(config, room);
  77. _initConference();
  78. }
  79. }
  80. }
  81. /**
  82. * Obtain config handler.
  83. *
  84. * @private
  85. * @returns {Promise}
  86. */
  87. function _obtainConfigHandler() {
  88. const now = window.performance.now();
  89. APP.connectionTimes['configuration.fetched'] = now;
  90. logger.log('(TIME) configuration fetched:\t', now);
  91. }