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

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