Detecting user is already connected

Is it possible to detect if a user is already logged into a jabber server? This way the application can inform the user that the they are already logged in and optionally quit or take over the connection. This way apps don’'t have to fight to share a connection.

Thanks,

Joe

Message was edited by: kisnetjoe

Joe,

Is it possible to detect if a user is already logged

into a jabber server? This way the application can

inform the user that the they are already logged in

and optionally quit or take over the connection.

You can check for the user’‘s presence to detect if a user is already logged into an XMPP server. You can check even if you are connected in another client and then react accordingly. FYI, your checking will be valid only if the other user didn’'t change his/her presence to invisible.

This way apps don’'t have to fight to share a connection.

I didn’'t understand why would they have to fight for a connection. If you have the same user connected twice (using different clients) then you will have a connection for each logged user.

Regards,

– Gato

At least some Jabber servers only allow a single session per user from a particular resource. The jabberd 1.4.x implementation, for example, drops a previously existing session if a user logs in again with the same resource.

This could put a crimp in your ability to check for existing user connections from multiple apps unless you do something to ensure resource uniqueness. Luckily, you can specify a resource using the three argument version of XMPPConnection.login().

I’‘m not sure if this behavior is related to XMPP standards or just a quirk, but it’'s worth knowing about.

Keith

I’'m not using Jabber as an IM client and my implementation needs to make sure a user is only logged in once.

In regards to checking items on a roster you have to be logged in to get the roster and a user doesn’'t show up on their own roster.

What I would prefer to do is to ask the server is the user is already authenticated.

Thanks for the reply.

Joe

It is tough to enforce one connection per user account from a client because XMPP is specifically designed to allow multiple connections on a single user account using ‘‘resources’’ to differentiate the different delivery points. The most reliable method to enforce the policy is on the server if you can modify the server behavior. What is the reason you want to restrict the number of simultaneous connections from a single user account? Perhaps there’'s another way to obtain the same outcome.

-iain