2014-11-28 15:16:04 +00:00
|
|
|
/* global $, $iq, config, connection, Strophe, toggleAudio */
|
2014-05-11 22:41:58 +00:00
|
|
|
/**
|
|
|
|
* Moderate connection plugin.
|
|
|
|
*/
|
|
|
|
Strophe.addConnectionPlugin('moderate', {
|
|
|
|
connection: null,
|
|
|
|
init: function (conn) {
|
|
|
|
this.connection = conn;
|
|
|
|
|
2014-11-28 15:16:04 +00:00
|
|
|
this.connection.addHandler(this.onMute.bind(this),
|
|
|
|
'http://jitsi.org/jitmeet/audio',
|
|
|
|
'iq',
|
|
|
|
'set',
|
|
|
|
null,
|
|
|
|
null);
|
2014-05-11 22:41:58 +00:00
|
|
|
},
|
2014-11-28 15:16:04 +00:00
|
|
|
setMute: function (jid, mute) {
|
2014-05-11 22:41:58 +00:00
|
|
|
var iq = $iq({to: jid, type: 'set'})
|
|
|
|
.c('mute', {xmlns: 'http://jitsi.org/jitmeet/audio'})
|
|
|
|
.t(mute.toString())
|
|
|
|
.up();
|
|
|
|
|
|
|
|
this.connection.sendIQ(
|
|
|
|
iq,
|
|
|
|
function (result) {
|
|
|
|
console.log('set mute', result);
|
|
|
|
},
|
|
|
|
function (error) {
|
|
|
|
console.log('set mute error', error);
|
2014-08-14 15:29:28 +00:00
|
|
|
messageHandler.openReportDialog(null, 'Failed to mute ' +
|
|
|
|
$("#participant_" + jid).find(".displayname").text() ||
|
|
|
|
"participant" + '.', error);
|
2014-05-11 22:41:58 +00:00
|
|
|
});
|
|
|
|
},
|
2014-11-28 15:16:04 +00:00
|
|
|
onMute: function (iq) {
|
2014-05-11 22:41:58 +00:00
|
|
|
var mute = $(iq).find('mute');
|
|
|
|
if (mute.length) {
|
|
|
|
toggleAudio();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
},
|
2014-11-28 15:16:04 +00:00
|
|
|
eject: function (jid) {
|
2014-05-11 22:41:58 +00:00
|
|
|
connection.jingle.terminateRemoteByJid(jid, 'kick');
|
|
|
|
connection.emuc.kick(jid);
|
|
|
|
}
|
|
|
|
});
|