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 { 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({ backend: new PostMessageTransportBackend({ postisOptions }) });
  34. }
  35. return transport;
  36. }
  37. /**
  38. * Sets the transport to passed transport.
  39. *
  40. * @param {Object} externalTransportBackend - The new transport.
  41. * @returns {void}
  42. */
  43. getJitsiMeetGlobalNS().setExternalTransportBackend = externalTransportBackend =>
  44. transport.setBackend(externalTransportBackend);