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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. const { initPromise } = state['features/base/lib-jitsi-meet'];
  27. // XXX For web based version we use conference initialization logic
  28. // from the old app (at the moment of writing).
  29. return initPromise.then(() => APP.conference.init({
  30. roomName: room
  31. })).catch(error => {
  32. APP.API.notifyConferenceLeft(APP.conference.roomName);
  33. logger.error(error);
  34. // TODO The following are in fact Errors raised by
  35. // JitsiMeetJS.init() which should be taken care of in
  36. // features/base/lib-jitsi-meet but we are not there yet on the
  37. // Web at the time of this writing.
  38. switch (error.name) {
  39. case WEBRTC_NOT_READY:
  40. case WEBRTC_NOT_SUPPORTED:
  41. dispatch(libInitError(error));
  42. }
  43. });
  44. };
  45. }
  46. /**
  47. * Closes connection.
  48. *
  49. * @param {boolean} [requestFeedback] - Whether or not to attempt showing a
  50. * request for call feedback.
  51. * @returns {Function}
  52. */
  53. export function disconnect(requestFeedback: boolean = false) {
  54. // XXX For web based version we use conference hanging up logic from the old
  55. // app.
  56. return () => APP.conference.hangup(requestFeedback);
  57. }