mod/bigbluebuttonbn/amd/src/events.js

  1. // This file is part of Moodle - http://moodle.org/
  2. //
  3. // Moodle is free software: you can redistribute it and/or modify
  4. // it under the terms of the GNU General Public License as published by
  5. // the Free Software Foundation, either version 3 of the License, or
  6. // (at your option) any later version.
  7. //
  8. // Moodle is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
  15. /**
  16. * Events for the mod_bigbluebuttonbn plugin.
  17. *
  18. * @module mod_bigbluebuttonbn/events
  19. * @copyright 2021 Blindside Networks Inc
  20. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  21. */
  22. import {dispatchEvent} from 'core/event_dispatcher';
  23. export const eventTypes = {
  24. /**
  25. * Fired when a session has been ended.
  26. *
  27. * @event mod_bigbluebuttonbn/sessionEnded
  28. * @type CustomEvent
  29. * @property {object} detail
  30. * @property {number} detail.bbbId
  31. * @property {number} detail.groupId
  32. */
  33. sessionEnded: 'mod_bigbluebuttonbn/sessionEnded',
  34. /**
  35. * Fired when the current session has been ended.
  36. *
  37. * @event mod_bigbluebuttonbn/currentSessionEnded
  38. * @type CustomEvent
  39. * @property {object} detail
  40. */
  41. currentSessionEnded: 'mod_bigbluebuttonbn/currentSessionEnded',
  42. };
  43. /**
  44. * Trigger the sessionEnded event.
  45. *
  46. * @param {number} bbbId
  47. * @param {number} groupId
  48. * @returns {CustomEvent}
  49. * @fires event:mod_bigbluebuttonbn/sessionEnded
  50. */
  51. export const notifySessionEnded = (bbbId, groupId) => dispatchEvent(eventTypes.sessionEnded, {
  52. bbbId,
  53. groupId,
  54. });
  55. /**
  56. * Trigger the currentSessionEnded event.
  57. *
  58. * @param {Element} container
  59. * @returns {CustomEvent}
  60. * @fires event:mod_bigbluebuttonbn/currentSessionEnded
  61. */
  62. export const notifyCurrentSessionEnded = container => dispatchEvent(
  63. eventTypes.currentSessionEnded,
  64. {},
  65. container
  66. );