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

do_external_connect.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* global config, createConnectionExternally */
  2. import {
  3. getRoomName,
  4. parseURLParams
  5. } from '../react/features/base/config/functions';
  6. /**
  7. * Implements external connect using createConnectionExternally function defined
  8. * in external_connect.js for Jitsi Meet. Parses the room name and token from
  9. * the URL and executes createConnectionExternally.
  10. *
  11. * NOTE: If you are using lib-jitsi-meet without Jitsi Meet you should use this
  12. * file as reference only because the implementation is Jitsi Meet-specific.
  13. *
  14. * NOTE: For optimal results this file should be included right after
  15. * external_connect.js.
  16. */
  17. const hashParams = parseURLParams(window.location, true);
  18. // URL params have higher proirity than config params.
  19. let url = hashParams['config.externalConnectUrl'] || config.externalConnectUrl;
  20. if (url && window.createConnectionExternally) {
  21. const roomName = getRoomName();
  22. if (roomName) {
  23. url += `?room=${roomName}`;
  24. let token = hashParams['config.token'] || config.token;
  25. if (!token) {
  26. const searchParams
  27. = parseURLParams(window.location, true, 'search');
  28. token = searchParams.jwt;
  29. }
  30. if (token) {
  31. url += `&token=${token}`;
  32. }
  33. createConnectionExternally(
  34. url,
  35. connectionInfo => {
  36. // Sets that global variable to be used later by connect method
  37. // in connection.js.
  38. window.XMPPAttachInfo = {
  39. status: 'success',
  40. data: connectionInfo
  41. };
  42. checkForConnectHandlerAndConnect();
  43. },
  44. errorCallback);
  45. } else {
  46. errorCallback();
  47. }
  48. } else {
  49. errorCallback();
  50. }
  51. /**
  52. * Check if connect from connection.js was executed and executes the handler
  53. * that is going to finish the connect work.
  54. *
  55. * @returns {void}
  56. */
  57. function checkForConnectHandlerAndConnect() {
  58. window.APP
  59. && window.APP.connect.status === 'ready'
  60. && window.APP.connect.handler();
  61. }
  62. /**
  63. * Implements a callback to be invoked if anything goes wrong.
  64. *
  65. * @param {Error} error - The specifics of what went wrong.
  66. * @returns {void}
  67. */
  68. function errorCallback(error) {
  69. // The value of error is undefined if external connect is disabled.
  70. error && console.warn(error);
  71. // Sets that global variable to be used later by connect method in
  72. // connection.js.
  73. window.XMPPAttachInfo = {
  74. status: 'error'
  75. };
  76. checkForConnectHandlerAndConnect();
  77. }