diff --git a/app.js b/app.js index dd4282683..f9081ad7f 100644 --- a/app.js +++ b/app.js @@ -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; } diff --git a/config.js b/config.js index c7abd9350..e85e37295 100644 --- a/config.js +++ b/config.js @@ -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 diff --git a/muc.js b/muc.js index 48cf26cd7..2e31bc9ac 100644 --- a/muc.js +++ b/muc.js @@ -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) {