Hey! I'd like to know when a user disconnects. Something like this, for example:
client.onRealtimeConnectionLost(() => {
databases.createDocument('main', 'messages', {message: `${currentUser.name} has left the game.`});
I hope my question is clear. Is it possible? If not, could you suggest some efficient workarounds? Thanks!
You might want to ππΌ this issue: https://github.com/appwrite/appwrite/issues/2418
For now, you can implement a heartbeat/pinging approach where the client sends a request every X interval to let the server know it's still around. After Y interval of no responses, the server would determine the user has left/disconnected
Thanks!
Um could you help me a bit more? Basically, a user needs to know if another user is on the same page.
Let's say I wrote an interval function that keeps pinging they're on that page but in what way?
I could have a collection for this. With documents like pageId = {currentlyPresent=["userId1", "userId2"]} etc and then subscribe to that particular document to get realtime update. But how do I actually detect there are two users concurrently on that page?
I'm sorry if I'm not making any sense but I hope you at least understand what I need.
you could have a presence collection with userId and page. when a user is on the page, a document will be created. the document will be updated as long as they're on the page. after inactivity, the document would be deleted.
The realtime would listen for documents in that collection and then do as needed
Recommended threads
- Realtime: Listener not triggered on upda...
I self host appwrite 1.8.1. The genereal functionallity works fine. But my realtime subscription isn't updating. I see "Received heartbeat response from realtim...
- Realtime for files() works almost well, ...
I have been trying to make use of realtime, today (14.03.26) I have pulled all the latest versions of docker images, and sdk available. Whats working: - Conn...
- π Realtime Flutter SDK Crash β Realtime...
**Summary** When using Appwrite Cloud with the Flutter SDK (latest appwrite release: 21.4.0), Realtime crashes with: ```Unhandled async error: type '_Map<String...