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.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 { PostMessageTransportBackend, Transport } from 'js-utils/transport';
  4. import { getJitsiMeetGlobalNS } from '../../react/features/base/util';
  5. import { API_ID } from '../API/constants';
  6. export {
  7. PostMessageTransportBackend,
  8. Transport
  9. };
  10. /**
  11. * Option for the default low level transport.
  12. *
  13. * @type {Object}
  14. */
  15. const postisOptions = {};
  16. if (typeof API_ID === 'number') {
  17. postisOptions.scope = `jitsi_meet_external_api_${API_ID}`;
  18. }
  19. /**
  20. * The instance of Transport class that will be used by Jitsi Meet.
  21. *
  22. * @type {Transport}
  23. */
  24. let transport;
  25. /**
  26. * Returns the instance of Transport class that will be used by Jitsi Meet.
  27. *
  28. * @returns {Transport}
  29. */
  30. export function getJitsiMeetTransport() {
  31. if (!transport) {
  32. transport = new Transport({ backend: new PostMessageTransportBackend({ postisOptions }) });
  33. }
  34. return transport;
  35. }
  36. /**
  37. * Sets the transport to passed transport.
  38. *
  39. * @param {Object} externalTransportBackend - The new transport.
  40. * @returns {void}
  41. */
  42. getJitsiMeetGlobalNS().setExternalTransportBackend = externalTransportBackend =>
  43. transport.setBackend(externalTransportBackend);