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.

index.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // FIXME: change to '../API' when we update to webpack2. If we do this now all
  2. // files from API modules will be included in external_api.js.
  3. import { API_ID } from '../API/constants';
  4. import { getJitsiMeetGlobalNS } from '../../react/features/base/util';
  5. import PostMessageTransportBackend from './PostMessageTransportBackend';
  6. import Transport from './Transport';
  7. export {
  8. PostMessageTransportBackend,
  9. Transport
  10. };
  11. /**
  12. * Option for the default low level transport.
  13. *
  14. * @type {Object}
  15. */
  16. const postisOptions = {};
  17. if (typeof API_ID === 'number') {
  18. postisOptions.scope = `jitsi_meet_external_api_${API_ID}`;
  19. }
  20. /**
  21. * The instance of Transport class that will be used by Jitsi Meet.
  22. *
  23. * @type {Transport}
  24. */
  25. let transport;
  26. /**
  27. * Returns the instance of Transport class that will be used by Jitsi Meet.
  28. *
  29. * @returns {Transport}
  30. */
  31. export function getJitsiMeetTransport() {
  32. if (!transport) {
  33. transport = new Transport({
  34. backend: new PostMessageTransportBackend({
  35. enableLegacyFormat: true,
  36. postisOptions
  37. })
  38. });
  39. }
  40. return transport;
  41. }
  42. /**
  43. * Sets the transport to passed transport.
  44. *
  45. * @param {Object} externalTransportBackend - The new transport.
  46. * @returns {void}
  47. */
  48. getJitsiMeetGlobalNS().setExternalTransportBackend = externalTransportBackend =>
  49. transport.setBackend(externalTransportBackend);