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 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* @flow */
  2. import type { Dispatch } from 'redux';
  3. import { JitsiConferenceEvents } from '../lib-jitsi-meet';
  4. import UIEvents from '../../../../service/UI/UIEvents';
  5. import { SET_DOMAIN } from './actionTypes';
  6. import { appNavigate } from '../../app';
  7. declare var APP: Object;
  8. const logger = require('jitsi-meet-logger').getLogger(__filename);
  9. export {
  10. connectionEstablished,
  11. connectionFailed
  12. } from './actions.native.js';
  13. /**
  14. * Opens new connection.
  15. *
  16. * @returns {Promise<JitsiConnection>}
  17. */
  18. export function connect() {
  19. return (dispatch: Dispatch<*>, getState: Function) => {
  20. const state = getState();
  21. // XXX Lib-jitsi-meet does not accept uppercase letters.
  22. const room = state['features/base/conference'].room.toLowerCase();
  23. // XXX For web based version we use conference initialization logic
  24. // from the old app (at the moment of writing).
  25. return APP.conference.init({ roomName: room }).then(() => {
  26. // If during the conference initialization was defined that browser
  27. // doesn't support WebRTC then we should define which route
  28. // to render.
  29. if (APP.unsupportedBrowser) {
  30. dispatch(appNavigate(room));
  31. }
  32. if (APP.logCollector) {
  33. // Start the LogCollector's periodic "store logs" task
  34. APP.logCollector.start();
  35. APP.logCollectorStarted = true;
  36. // Make an attempt to flush in case a lot of logs have been
  37. // cached, before the collector was started.
  38. APP.logCollector.flush();
  39. // This event listener will flush the logs, before
  40. // the statistics module (CallStats) is stopped.
  41. //
  42. // NOTE The LogCollector is not stopped, because this event can
  43. // be triggered multiple times during single conference
  44. // (whenever statistics module is stopped). That includes
  45. // the case when Jicofo terminates the single person left in the
  46. // room. It will then restart the media session when someone
  47. // eventually join the room which will start the stats again.
  48. APP.conference.addConferenceListener(
  49. JitsiConferenceEvents.BEFORE_STATISTICS_DISPOSED,
  50. () => {
  51. if (APP.logCollector) {
  52. APP.logCollector.flush();
  53. }
  54. }
  55. );
  56. }
  57. APP.UI.initConference();
  58. APP.UI.addListener(UIEvents.LANG_CHANGED, language => {
  59. APP.translation.setLanguage(language);
  60. APP.settings.setLanguage(language);
  61. });
  62. APP.keyboardshortcut.init();
  63. })
  64. .catch(err => {
  65. APP.UI.hideRingOverLay();
  66. APP.API.notifyConferenceLeft(APP.conference.roomName);
  67. logger.error(err);
  68. });
  69. };
  70. }
  71. /**
  72. * Closes connection.
  73. *
  74. * @returns {Function}
  75. */
  76. export function disconnect() {
  77. // XXX For web based version we use conference hanging up logic from the old
  78. // app.
  79. return () => APP.conference.hangup();
  80. }
  81. /**
  82. * Sets connection domain.
  83. *
  84. * @param {string} domain - Domain name.
  85. * @returns {{
  86. * type: SET_DOMAIN,
  87. * domain: string
  88. * }}
  89. */
  90. export function setDomain(domain: string) {
  91. return {
  92. type: SET_DOMAIN,
  93. domain
  94. };
  95. }