Maggie
Maggie

Reputation: 8081

Can XMPP client connect to server if the same JID is already connected?

I'm implementing an xmpp client (in Java). Is it possible for the client, prior to connecting to server, to check if the connection for the given JID already exists?
According to the: can client of the xmpp server disconnect other client from the server? , server usually disconnects the old connection if the same full jid in the form "user@host/resource" connects from two different sources. If the user connects from eg. Pidgin, web client and my client, won't "resource" always be different? Is it possible to check with the server if the connection for the jid in the form "user@host" already exists, disregarding the resource part?

Upvotes: 0

Views: 919

Answers (3)

ggarber
ggarber

Reputation: 8360

You can connect with user@host/XXX and then after sending a presence message to your own Bare Jid (user@host) you should receive presence messages from any other client connected with the same Bare Jid (user@host).

Upvotes: 3

putolaruan
putolaruan

Reputation: 2054

If the user connects from eg. Pidgin, web client and my client, won't "resource" always be different?

Yes, there would be different resources for each. You can assign one or as Joe Hildebrand said, you can just let the server create a random resource string for you.. So to answer your question..

Can XMPP client connect to server if the same JID is already connected?

Yes you can.

Upvotes: 0

Joe Hildebrand
Joe Hildebrand

Reputation: 10414

Your best bet is to just let the server pick the resource for you. See section 7.6.1 of RFC 6120:

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

S: <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>

Upvotes: 1

Related Questions