views:

24

answers:

1

Hi, I have a GChome extension that listens to XMPP server. I use Strophe for BOSH connection. The issue is "how should I handle connection?" from the XMPP core wiki, I found that the last connected/prioritized client receives messages. And when user is logged in from other place Extension stops receiving message. How can I manage this connection absence. I hope the question is not very ambiguous =).

A: 

Make sure you use a different resource for each connection. The easiest way to do this is to have the server generate the resource name, as specified in RFC 3920bis, section 7.5, by having your client send:

<iq id='tn281v37' type='set'>
  <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/>
</iq>

And watching for the server to respond with the full generated Jabber ID:

<iq id='tn281v37' type='result'>
  <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
    <jid>
      [email protected]/4db06f06-1ea4-11dc-aca3-000bcd821bfb
    </jid>
  </bind>
</iq>

Keep in mind that the server may enforce a maximum number of resources, so you might get an error:

<iq id='wy2xa82b4' type='error'>
  <error type='wait'>
    <resource-constraint
        xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  </error>
</iq>
Joe Hildebrand