Detects focus user in reliable way(through user real JID). Fixes kicked event when both 307 and 110 status codes are received in MUC presence.

This commit is contained in:
paweldomas 2014-11-28 16:21:01 +01:00
parent 871c661ba9
commit 8f94ac8b09
3 changed files with 16 additions and 10 deletions

9
app.js
View File

@ -710,10 +710,10 @@ $(document).bind('entered.muc', function (event, jid, info, pres) {
'connected',
'connected');
if (Strophe.getResourceFromJid(jid).indexOf('focus') != -1)
if (info.isFocus)
{
focusJid = jid;
console.info("Ignore focus " + jid);
console.info("Ignore focus: " + jid +", real JID: " + info.jid);
return;
}
@ -828,10 +828,9 @@ $(document).bind('presence.muc', function (event, jid, info, pres) {
if (displayName && displayName.length > 0)
$(document).trigger('displaynamechanged',
[jid, displayName]);
if (Strophe.getResourceFromJid(jid).indexOf('focus') != -1)
[jid, info.displayName]);
if (info.isFocus)
{
console.info("Ignore focus");
return;
}

View File

@ -13,6 +13,7 @@ var config = {
useNicks: false,
bosh: '//jitsi-meet.example.com/http-bind', // FIXME: use xep-0156 for that
clientNode: 'http://jitsi.org/jitsimeet', // The name of client node advertised in XEP-0115 'c' stanza
focusUserJid: 'focus@auth.pawel.jitsi.net', // The real JID of focus participant
//defaultSipNumber: '', // Default SIP number
desktopSharing: 'ext', // Desktop sharing method. Can be set to 'ext', 'webrtc' or false to disable.
chromeExtensionId: 'diibjkoicjeejcmhdnailmkgecihlobk', // Id of desktop streamer Chrome extension

16
muc.js
View File

@ -123,6 +123,13 @@ Strophe.addConnectionPlugin('emuc', {
member.affiliation = tmp.attr('affiliation');
member.role = tmp.attr('role');
// Focus recognition
member.jid = tmp.attr('jid');
member.isFocus = false;
if (member.jid && member.jid.indexOf(config.focusUserJid + "/") == 0) {
member.isFocus = true;
}
var nicktag = $(pres).find('>nick[xmlns="http://jabber.org/protocol/nick"]');
member.displayName = (nicktag.length > 0 ? nicktag.text() : null);
@ -167,11 +174,7 @@ Strophe.addConnectionPlugin('emuc', {
if (!$(pres).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>status[code="110"]').length) {
delete this.members[from];
this.list_members.splice(this.list_members.indexOf(from), 1);
if ($(pres).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>status[code="307"]').length) {
$(document).trigger('kicked.muc', [from]);
} else {
$(document).trigger('left.muc', [from]);
}
$(document).trigger('left.muc', [from]);
}
// If the status code is 110 this means we're leaving and we would like
// to remove everyone else from our view, so we trigger the event.
@ -183,6 +186,9 @@ Strophe.addConnectionPlugin('emuc', {
$(document).trigger('left.muc', member);
}
}
if ($(pres).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>status[code="307"]').length) {
$(document).trigger('kicked.muc', [from]);
}
return true;
},
onPresenceError: function (pres) {