Check if a user is logged on
Posted: 02 May 2008 10:46 PM   [ Ignore ]
Newbie
Rank
Total Posts:  1
Joined  2008-05-02

Hi.

Is there an API call I can do in order to check if a user is currently online?

Thanks!
--
Tor-Helge Persett

Profile
 
 
Posted: 23 June 2008 06:31 PM   [ Ignore ]   [ # 1 ]
Newbie
Rank
Total Posts:  2
Joined  2008-06-23

Bumpage. Also looking for an answer to this question.

Profile
 
 
Posted: 25 June 2008 06:54 PM   [ Ignore ]   [ # 2 ]
Newbie
Rank
Total Posts:  2
Joined  2008-06-23

Been digging around in the ejabberd code base a little, think I found out how you would accomplish this:

ejabberd_sm:get_user_resources(User, Server)

That will return an empty list if the user isn’t logged on, and if they are logged on, it will return a list containing all the resources that the user is logged on with. So if you’re just looking for whether they’re logged in or not, checking the size or contents of the list returned should tell you that. This is actually published here: http://www.process-one.net/en/wiki/ejabberd_sm/, as part of the session manager API, I just didn’t know what it’s behavior would be for users that aren’t logged on until I saw it in action in some of the ejabberd source code.

Profile