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

do_external_connect.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 JSON Web
  9. * Token (JWT) from 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. if (typeof createConnectionExternally === 'function') {
  18. // URL params have higher proirity than config params.
  19. let url
  20. = parseURLParams(window.location, true, 'hash')[
  21. 'config.externalConnectUrl']
  22. || config.externalConnectUrl;
  23. let roomName;
  24. if (url && (roomName = getRoomName())) {
  25. url += `?room=${roomName}`;
  26. const token = parseURLParams(window.location, true, 'search').jwt;
  27. if (token) {
  28. url += `&token=${token}`;
  29. }
  30. createConnectionExternally(
  31. url,
  32. connectionInfo => {
  33. // Sets that global variable to be used later by connect method
  34. // in connection.js.
  35. window.XMPPAttachInfo = {
  36. status: 'success',
  37. data: connectionInfo
  38. };
  39. checkForConnectHandlerAndConnect();
  40. },
  41. errorCallback);
  42. } else {
  43. errorCallback();
  44. }
  45. } else {
  46. errorCallback();
  47. }
  48. /**
  49. * Check if connect from connection.js was executed and executes the handler
  50. * that is going to finish the connect work.
  51. *
  52. * @returns {void}
  53. */
  54. function checkForConnectHandlerAndConnect() {
  55. window.APP
  56. && window.APP.connect.status === 'ready'
  57. && window.APP.connect.handler();
  58. }
  59. /**
  60. * Implements a callback to be invoked if anything goes wrong.
  61. *
  62. * @param {Error} error - The specifics of what went wrong.
  63. * @returns {void}
  64. */
  65. function errorCallback(error) {
  66. // The value of error is undefined if external connect is disabled.
  67. error && console.warn(error);
  68. // Sets that global variable to be used later by connect method in
  69. // connection.js.
  70. window.XMPPAttachInfo = {
  71. status: 'error'
  72. };
  73. checkForConnectHandlerAndConnect();
  74. }