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

Receiver.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* global APP, JitsiMeetJS */
  2. import {DISCO_REMOTE_CONTROL_FEATURE, API_EVENT_TYPE}
  3. from "../../service/remotecontrol/Constants";
  4. const ConferenceEvents = JitsiMeetJS.events.conference;
  5. /**
  6. * This class represents the receiver party for a remote controller session.
  7. * It handles "remote-control-event" events and sends them to the
  8. * API module. From there the events can be received from wrapper application
  9. * and executed.
  10. */
  11. export default class Receiver {
  12. /**
  13. * Creates new instance.
  14. * @constructor
  15. */
  16. constructor() {
  17. this.enabled = false;
  18. }
  19. /**
  20. * Enables / Disables the remote control
  21. * @param {boolean} enabled the new state.
  22. */
  23. enable(enabled) {
  24. if(this.enabled !== enabled && enabled === true) {
  25. this.enabled = enabled;
  26. // Announce remote control support.
  27. APP.connection.addFeature(DISCO_REMOTE_CONTROL_FEATURE, true);
  28. }
  29. }
  30. /**
  31. * Attaches listener for ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED events.
  32. */
  33. start() {
  34. if(this.enabled) {
  35. APP.conference.addConferenceListener(
  36. ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
  37. this._onRemoteControlEvent);
  38. }
  39. }
  40. /**
  41. * Removes the listener for ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED
  42. * events.
  43. */
  44. stop() {
  45. APP.conference.removeConferenceListener(
  46. ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
  47. this._onRemoteControlEvent);
  48. }
  49. /**
  50. * Sends "remote-control-event" events to to the API module.
  51. * @param {JitsiParticipant} participant the controller participant
  52. * @param {Object} event the remote control event.
  53. */
  54. _onRemoteControlEvent(participant, event) {
  55. if(event.type === API_EVENT_TYPE && this.enabled)
  56. APP.API.sendRemoteControlEvent(event.event);
  57. }
  58. }