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

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