How can I determine if a user (JID) is logged in when using XMPP?

In my chat application, I want to implement a functionality that, when a user is already logged in, and if he / she wants to log in again on another device using the same username and password, he must return the message to the user - "You are already logged in another place"

I only know this method for checking login status -

connection.isConnected();

But that will not be my goal.

+5
source share
2 answers

Alex's answer is correct, but let me tell you more about him:

XMPP-IM . JID 'from' 'both' (RFC6121 XMPP-IM 4.2.2 4.4.2).

4.4.2 :

The user server MUST also send the presence stanza to all of the user 
available resources (including the resource that generated the presence
notification in the first place).

, JID. JID, , , ( ,...) JID, " ".

, , XMPP, , JID, XMPP-IM.

smack Iterator<Presence> Roster.getPresences(String user). : getPresences(XMPPConnection.getUser()). ( , , ).

+4

, , (). , .

+3

All Articles