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

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