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.

actions.web.js 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* @flow */
  2. import type { Dispatch } from 'redux';
  3. import {
  4. libInitError,
  5. WEBRTC_NOT_READY,
  6. WEBRTC_NOT_SUPPORTED
  7. } from '../lib-jitsi-meet';
  8. declare var APP: Object;
  9. declare var config: Object;
  10. const logger = require('jitsi-meet-logger').getLogger(__filename);
  11. export {
  12. connectionEstablished,
  13. connectionFailed,
  14. setLocationURL
  15. } from './actions.native';
  16. /**
  17. * Opens new connection.
  18. *
  19. * @returns {Promise<JitsiConnection>}
  20. */
  21. export function connect() {
  22. return (dispatch: Dispatch<*>, getState: Function) => {
  23. const state = getState();
  24. // XXX Lib-jitsi-meet does not accept uppercase letters.
  25. const room = state['features/base/conference'].room.toLowerCase();
  26. // XXX For web based version we use conference initialization logic
  27. // from the old app (at the moment of writing).
  28. return APP.conference.init({ roomName: room })
  29. .catch(error => {
  30. APP.API.notifyConferenceLeft(APP.conference.roomName);
  31. logger.error(error);
  32. // TODO The following are in fact Errors raised by
  33. // JitsiMeetJS.init() which should be taken care of in
  34. // features/base/lib-jitsi-meet but we are not there yet on the
  35. // Web at the time of this writing.
  36. switch (error.name) {
  37. case WEBRTC_NOT_READY:
  38. case WEBRTC_NOT_SUPPORTED:
  39. dispatch(libInitError(error));
  40. }
  41. });
  42. };
  43. }
  44. /**
  45. * Closes connection.
  46. *
  47. * @returns {Function}
  48. */
  49. export function disconnect() {
  50. // XXX For web based version we use conference hanging up logic from the old
  51. // app.
  52. return () => APP.conference.hangup();
  53. }