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

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