Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

detect LiveQuery connected clients on parse Server

how do i can detect when client connects via liveQuery to parse server. I want to updata some data in MongoDB on client's Disconnect Event by Server. Log display on Server but how i can call some function after detection of this event.

I am using self hosted Parse SErver. connect client lists on server

thanks in advance

like image 291
AAhmad Blal Avatar asked Dec 17 '25 12:12

AAhmad Blal


1 Answers

Here you go:

Parse.Cloud.onLiveQueryEvent( ({event, clients, subscriptions, error}) => {
  if (event !== 'ws_disconnect') {
    return;
  }
  // Do your magic
});

In case you were wondering, these are the currently emitted events:

  • connect
  • subscribe
  • unsubscribe
  • ws_connect
  • ws_disconnect
  • ws_disconnect_error

"connect" differs from "ws_connect", the former means that the client completed the connect procedure as defined by Parse livequery protocol, where "ws_connect" just means that a new websocket was created.

like image 193
Roman Avatar answered Dec 19 '25 06:12

Roman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!