Ejabberd is an XMPP application server that can run under several Unix-like operating systems like GNU/Linux, FreeBSD, Mac OS X, OpenBSD, NetBSD, and OpenSolaris. Now, it also runs under Microsoft Windows.
This tutorial will guide you how to enable shared roster to view every registered user of the app. This is one of those rare tutorials where you don’t have to code – just follow these simple steps to enable shared virtual roster.
Do you want to see all users, who are registered in a chatting application? Do you want to know who is online although he/she is not on your friend list, but registered in an application?
One of our clients wanted to integrate the same feature that shows the online/offline status of other users so the user can ping him/her straight away and start chatting.
As it was a “Dating App”, we only have to show ‘potential partners’, there is no concept of adding any users as Friend/Buddy. Of course, users can add Buddy when they start chatting.
But, what about the new users, who have just registered to find their dates? For those users, our app development team has provided the solution with Ejabberd.
As Ejabberd doesn’t provide ONLINE/OFFLINE status of each user thus, we have provided below two solutions to our client in which the first solution is not recommended as managing two servers cost more and slower down performance.
Solution 1: Manage Internal Buddy list from API side. (NOT RECOMMENDED)
The first solution is to add a User into the Buddy List of All the users. That means whenever any user is created, make an API call to a server from an app. the created custom API will call the “ADD BUDDY” API of Ejabberd.
In this way, every new user will be the BUDDY of every user. And, all the users will able to see all users with their status.
However, this solution is not recommended, as it includes two servers, i.e. custom API server, and Ejabberd server. It becomes costly to manage two servers, and it also slowed down the performance. So, we have recommended and integrated the second solution.
Solution 2: Configure Ejabberd to show all Friends to Every User. (RECOMMENDED)
Here, we are going to configure Ejabberd in such a way that shows all the users to every registered user. This is the fastest and industry standard solution, as it includes only one (Ejabberd) server.
Follow below configuration steps to achieve the desired functionality.
Enable mod_shared_roster in ejabberd.cfg
Login to Ejabberd web admin and Go to Virtual Hosts >> Server >> Shared Roster
Create a new Shared Roster, with identifier ‘everybody’. Click on ‘Add new’.
Enter the following information as shown in the image and click on ‘Submit’.
- Name: EveryBody
- Description: This group contains everybody
- Members: @all@
- Displayed Groups: everybody
Now, whenever any user login OR register, he/she will see a new group on his/her roster, called EveryBody. In that group, all the registered users will able to see all OTHER USERS, who are registered on the server.
In this Ejabberd tutorial, you learned how to enable shared roster of an application. Space-O is a reliable mobile app development company, and one of our developers has written a post on how to manage offline push notification in Ejabberd XMPP server. You can check it out. It explains the whole concept through step by step guide.
I hope you enjoyed this Ejabberd tutorial, and if you have any questions or comments, please share through the comment section below.