3
votes

I have a OpenFire server running (it is using MySQL as it's database) and I'm trying to make a PHP http pre-bind system(using SASL) work with my web app.

I have got to a part of my app where I need to choose a random username that is not already online(for guest users). I was thinking of choosing some random users(in the Guests group I've created) and using the Presence Service plugin to check their online status until I find an available one(a user that's offline).

Is there a better way to get a list of offline/online users?

Does the server store the online status of users in the db? I've been looking around the OpenFire db but I can't figure it out.

Thanks.

2

2 Answers

3
votes

I wrote a small plugin for Openfire (with help of some other really simple plugin that I could plug without having to dig through the Openfire API docs) which basically spits out a JSON encoded list of users online. I could then just grab this and run json_decode and cycle through the array. I can't find the source at the moment, but it seems someone else made this aswell:

http://community.igniterealtime.org/thread/45107

EDIT:

I notice the Github project linked to in the above post is now gone, but I would try contacting them and see if they still have it.

ANOTHER EDIT:

Link to the Github repo: https://github.com/candy-chat/onlineUsersPlugin

1
votes

In roster of the user, You can get online and offline users. Also you can get status message of online users from the roster.

But for that u have to subscribe the presence of that user. Only adding that user in roster is not enough you have to subscribe the presence of that user then you can get presence of other users.