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

moderatemuc.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* global $, $iq, config, connection, focusJid, forceMuted, messageHandler,
  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: focusJid, 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. // FIXME: this causes an exception
  34. //messageHandler.openReportDialog(null, 'Failed to mute ' +
  35. // $("#participant_" + jid).find(".displayname").text() ||
  36. //"participant" + '.', error);
  37. });
  38. },
  39. onMute: function (iq) {
  40. var from = iq.getAttribute('from');
  41. if (from !== focusJid) {
  42. console.warn("Ignored mute from non focus peer");
  43. return false;
  44. }
  45. var mute = $(iq).find('mute');
  46. if (mute.length) {
  47. var doMuteAudio = mute.text() === "true";
  48. setAudioMuted(doMuteAudio);
  49. forceMuted = doMuteAudio;
  50. }
  51. return true;
  52. },
  53. eject: function (jid) {
  54. // We're not the focus, so can't terminate
  55. //connection.jingle.terminateRemoteByJid(jid, 'kick');
  56. connection.emuc.kick(jid);
  57. }
  58. });