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

View File

@ -13,6 +13,7 @@ var config = {
useNicks: false, useNicks: false,
bosh: '//jitsi-meet.example.com/http-bind', // FIXME: use xep-0156 for that 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 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 //defaultSipNumber: '', // Default SIP number
desktopSharing: 'ext', // Desktop sharing method. Can be set to 'ext', 'webrtc' or false to disable. desktopSharing: 'ext', // Desktop sharing method. Can be set to 'ext', 'webrtc' or false to disable.
chromeExtensionId: 'diibjkoicjeejcmhdnailmkgecihlobk', // Id of desktop streamer Chrome extension chromeExtensionId: 'diibjkoicjeejcmhdnailmkgecihlobk', // Id of desktop streamer Chrome extension

14
muc.js
View File

@ -123,6 +123,13 @@ Strophe.addConnectionPlugin('emuc', {
member.affiliation = tmp.attr('affiliation'); member.affiliation = tmp.attr('affiliation');
member.role = tmp.attr('role'); 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"]'); var nicktag = $(pres).find('>nick[xmlns="http://jabber.org/protocol/nick"]');
member.displayName = (nicktag.length > 0 ? nicktag.text() : null); member.displayName = (nicktag.length > 0 ? nicktag.text() : null);
@ -167,12 +174,8 @@ Strophe.addConnectionPlugin('emuc', {
if (!$(pres).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>status[code="110"]').length) { if (!$(pres).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>status[code="110"]').length) {
delete this.members[from]; delete this.members[from];
this.list_members.splice(this.list_members.indexOf(from), 1); 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 // 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. // to remove everyone else from our view, so we trigger the event.
else if (this.list_members.length > 1) { else if (this.list_members.length > 1) {
@ -183,6 +186,9 @@ Strophe.addConnectionPlugin('emuc', {
$(document).trigger('left.muc', member); $(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; return true;
}, },
onPresenceError: function (pres) { onPresenceError: function (pres) {