Back

[SOLVED] How can i check user presence (online/offline) status? Or websocket connection alive or not

  • 0
  • Web
  • Accounts
  • Self Hosted
  • Functions
  • Users
xue
14 Oct, 2023, 15:41

*This is requested feature here and here

Im trying to add this feature with different ways that are currently available features on appwrite.

(This is a wild way, not exactly a realtime presence feature)

So i created a function which is triggering by the event of user actions such as session, database requests and so on. It means user is recently online when user creates any session, document or so on .. i can understand user is alive/online or i can update user lastSeen status. i can show the user is something like "Recently Online 🟒" for 5minutes then no action after 5m, i can show he was online "5min ago πŸ”΄" bla bla.

(This is a wild way, not exactly a realtime presence feature)

However;

How can i understand or is there any better way that i can understand the user is away or offline. I need an idea about it.

For example in the console dashboard, i can easily see that how many there are realtime connections or not. Console is tracking active web sockets but i can not.

Is there any better way to handle with this situation ?

TL;DR
The user is asking for a way to check the online/offline status of users or the status of a websocket connection. One solution suggested is to implement a ping system where the backend is pinged from the clients with a timeout. Another solution mentioned is to have a collection with user IDs as document IDs and an attribute with the latest connection date/time. This attribute gets updated every 1-2 minutes when the user is online, and if it doesn't get updated after that time, the user is considered offline. The user also mentions a current method they are using which involves triggering a function based on user actions, but acknowledges that it is
D5
14 Oct, 2023, 16:23

I think the current way is by making a ping system

D5
14 Oct, 2023, 16:25

You have a collection where you have an attribute with user ID as document ID and an attribute with the latest connection date/time. When the user is online you update the field to current time every 1/2 minutes. If it doesn't gets updated after that time, user is offline

xue
14 Oct, 2023, 21:15

Thanks you for your perspective, i think its the most effective way to ping to backend from clients with timeout πŸ™‚

xue
14 Oct, 2023, 21:16

[SOLVED] How can i check user presence (online/offline) status? Or websocket connection alive or not

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more