您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

actions.web.js 3.2KB

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