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

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