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.

RemoteControlParticipant.js 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* global APP */
  2. const logger = require("jitsi-meet-logger").getLogger(__filename);
  3. import {REMOTE_CONTROL_EVENT_TYPE}
  4. from "../../service/remotecontrol/Constants";
  5. export default class RemoteControlParticipant {
  6. /**
  7. * Creates new instance.
  8. */
  9. constructor() {
  10. this.enabled = false;
  11. }
  12. /**
  13. * Enables / Disables the remote control
  14. * @param {boolean} enabled the new state.
  15. */
  16. enable(enabled) {
  17. this.enabled = enabled;
  18. }
  19. /**
  20. * Sends remote control event to other participant trough data channel.
  21. * @param {RemoteControlEvent} event the remote control event.
  22. * @param {Function} onDataChannelFail handler for data channel failure.
  23. */
  24. _sendRemoteControlEvent(to, event, onDataChannelFail = () => {}) {
  25. if(!this.enabled || !to) {
  26. logger.warn("Remote control: Skip sending remote control event."
  27. + " Params:", this.enable, to);
  28. return;
  29. }
  30. try{
  31. APP.conference.sendEndpointMessage(to,
  32. {type: REMOTE_CONTROL_EVENT_TYPE, event});
  33. } catch (e) {
  34. logger.error("Failed to send EndpointMessage via the datachannels",
  35. e);
  36. onDataChannelFail(e);
  37. }
  38. }
  39. }