Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

RemoteControlParticipant.js 1.3KB

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