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

moderatemuc.js 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* global $, $iq, config, connection, focusMucJid, forceMuted,
  2. setAudioMuted, Strophe, toggleAudio */
  3. /**
  4. * Moderate connection plugin.
  5. */
  6. Strophe.addConnectionPlugin('moderate', {
  7. connection: null,
  8. init: function (conn) {
  9. this.connection = conn;
  10. this.connection.addHandler(this.onMute.bind(this),
  11. 'http://jitsi.org/jitmeet/audio',
  12. 'iq',
  13. 'set',
  14. null,
  15. null);
  16. },
  17. setMute: function (jid, mute) {
  18. console.info("set mute", mute);
  19. var iqToFocus = $iq({to: focusMucJid, type: 'set'})
  20. .c('mute', {
  21. xmlns: 'http://jitsi.org/jitmeet/audio',
  22. jid: jid
  23. })
  24. .t(mute.toString())
  25. .up();
  26. this.connection.sendIQ(
  27. iqToFocus,
  28. function (result) {
  29. console.log('set mute', result);
  30. },
  31. function (error) {
  32. console.log('set mute error', error);
  33. });
  34. },
  35. onMute: function (iq) {
  36. var from = iq.getAttribute('from');
  37. if (from !== focusMucJid) {
  38. console.warn("Ignored mute from non focus peer");
  39. return false;
  40. }
  41. var mute = $(iq).find('mute');
  42. if (mute.length) {
  43. var doMuteAudio = mute.text() === "true";
  44. setAudioMuted(doMuteAudio);
  45. forceMuted = doMuteAudio;
  46. }
  47. return true;
  48. },
  49. eject: function (jid) {
  50. // We're not the focus, so can't terminate
  51. //connection.jingle.terminateRemoteByJid(jid, 'kick');
  52. connection.emuc.kick(jid);
  53. }
  54. });