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

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. name: REMOTE_CONTROL_EVENT_TYPE,
  33. ...event
  34. });
  35. } catch (e) {
  36. logger.error("Failed to send EndpointMessage via the datachannels",
  37. e);
  38. onDataChannelFail(e);
  39. }
  40. }
  41. }