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.

moderatemuc.js 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * Moderate connection plugin.
  3. */
  4. Strophe.addConnectionPlugin('moderate', {
  5. connection: null,
  6. roomjid: null,
  7. myroomjid: null,
  8. members: {},
  9. list_members: [], // so we can elect a new focus
  10. presMap: {},
  11. preziMap: {},
  12. joined: false,
  13. isOwner: false,
  14. init: function (conn) {
  15. this.connection = conn;
  16. this.connection.addHandler( this.onMute.bind(this),
  17. 'http://jitsi.org/jitmeet/audio',
  18. 'iq',
  19. 'set',
  20. null,
  21. null);
  22. },
  23. setMute: function(jid, mute) {
  24. var iq = $iq({to: jid, type: 'set'})
  25. .c('mute', {xmlns: 'http://jitsi.org/jitmeet/audio'})
  26. .t(mute.toString())
  27. .up();
  28. this.connection.sendIQ(
  29. iq,
  30. function (result) {
  31. console.log('set mute', result);
  32. },
  33. function (error) {
  34. console.log('set mute error', error);
  35. });
  36. },
  37. onMute: function(iq) {
  38. var mute = $(iq).find('mute');
  39. if (mute.length) {
  40. toggleAudio();
  41. }
  42. return true;
  43. },
  44. eject: function(jid) {
  45. connection.jingle.terminateRemoteByJid(jid, 'kick');
  46. connection.emuc.kick(jid);
  47. }
  48. });