forked from jitsi/jitsi-meet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
moderatemuc.js
53 lines (51 loc) · 1.62 KB
/
moderatemuc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* Moderate connection plugin.
*/
Strophe.addConnectionPlugin('moderate', {
connection: null,
roomjid: null,
myroomjid: null,
members: {},
list_members: [], // so we can elect a new focus
presMap: {},
preziMap: {},
joined: false,
isOwner: false,
init: function (conn) {
this.connection = conn;
this.connection.addHandler( this.onMute.bind(this),
'http://jitsi.org/jitmeet/audio',
'iq',
'set',
null,
null);
},
setMute: function(jid, mute) {
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);
messageHandler.openReportDialog(null, 'Failed to mute ' +
$("#participant_" + jid).find(".displayname").text() ||
"participant" + '.', error);
});
},
onMute: function(iq) {
var mute = $(iq).find('mute');
if (mute.length) {
toggleAudio();
}
return true;
},
eject: function(jid) {
connection.jingle.terminateRemoteByJid(jid, 'kick');
connection.emuc.kick(jid);
}
});