Designing a simple interface where real-time user presence can be shown

Can anyone help me with , that how can I implement the concept of displaying the real-time various user presence (similar to the case where in whatsapp, online status is shown) . I want to implement the concept in android using JAVA. Please if anyone knows the steps do let me know!
Thank you in advance :slight_smile:

@Anand_S_Pai : You can implement something similar with the help of data observables, something like this

Also, you can take reference of that repo for how to build chat client based on this article

User presence is a challenge with Realm; it doesn’t have a baked in user presence system.

(please feel free to correct me if that has changed)

While you can monitor when a user is Online or Offline by setting a flag or var when they log in or log out (for example) - there’s no way to monitor in-between or unexpected changes of presence.

For example, a user logs in - the app sets a sets a var (stored on the server) to ‘Online’ that other users are observing so their UI can be updated. Whenever that flag changes, other users know about it.

But what if the app crashes, the user d/c’s for whatever reason or the user force-quits the app. That var is now “Stuck” to the on position and other users would never know they were offline.

There are a number of solutions but for the moment, none of them involve Realm/MongoDB.

You can craft your own using a CRON job where an external source ‘checks in’ with your device periodically (or vice versa) and if it doesn’t respond, the server issuing the ‘ping’ can set that var on the Realm server to Offline.

Another option is to use built in functionality of the Firebase Realtime Database onDisconnect function - it has a user presence system built in and if the user d/c’s it knows about it, can set a server var to Offline and trigger a cloud function which could then update the MongoDB Realm server.

Another option is a timer on the app that updates a node on the server that the server is monitoring. If the time difference between the last time it was written to and the current time is say, greater than 1 minute, the server will set the user presence flag to offline. The downside here is that it’s additional network activity and writing of data.