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

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