How to monitor user's status?

I used LiveQuery to query online users with the status “ONLINE” but if one of them disconnect from the internet, I have no chance of knowing it. Is it possible to monitor disconnected LiveQuery from the server and update it’s status on the server based on user’s id and class that got disconnected?

I found that Parse Server have onLiveQueryEvent but I don’t know how to use the values provided to change the status of user that got disconnected to “OFFLINE” based on his ID and class.

Something like this should work for you:

}) => {
  if (event === 'ws_disconnect') {
    // Do your magic using the installationId

Yes, I thought so too, but installationId was undefined. I’ll try with the latest version and come back to you. Thanks.

Yes. I think it was recently added. Actually not even sure if it was already released. Maybe you could try against master. Let me know.

I tried the solution provided but the problem is that it’s not the only subscriptions I have, It’s hard to differentiate live query without class.

I didn’t get it. Can you provide some code and/or an example?

I misunderstood my own use case. I got it now; however, regarding the installationId, it was still undefined even in the latest version. here’s what I got { event: 'ws_disconnect', clients: 0, subscriptions: 0 }. Similar case when pushing ws_connect

Just to be registered here, as we talked in the Parse Server repo, the fix will be available in the next release.

1 Like