LiveQueryClient
for such scenarios.LiveQueryClient
is a wrapper of a standard WebSocket client. We add several useful methods to help you connect/disconnect to LiveQueryServer and subscribe/unsubscribe a MoralisQuery
easily.applicationId
(required): it's the applicationId
of your Moralis Dapp.serverURL
(required): it's the URL of your LiveQuery server.javascriptKey
masterKey
javascriptKey
and masterKey
are used for verifying the LiveQueryClient
when it tries to connect to the LiveQuery server. If you set them, they should match your Moralis app. You can check the LiveQuery protocol here for more details.LiveQueryClient
will try to send a connect request to the LiveQuery server.query
(required): it is the MoralisQuery
you'll want to subscribe.sessionToken
: If you provide the sessionToken
, the LiveQuery server will only send updates to clients whose sessionToken is fit for the MoralisObject
s ACL. You can check the LiveQuery protocol here for more details.subscription
you get is the same subscription
you receive from our Standard API. You can check our Standard API about how to use the subscription
to get events.subscription
(required): It's the subscription you want to unsubscribe from.LiveQueryClient
, cancel the auto-reconnect, and unsubscribe all subscriptions based on it.LiveQueryClient
.Moralis.LiveQuery.close()
or client.close()
, we'll cancel the auto-reconnect.sessionToken
to the LiveQuery server when you subscribe to a MoralisQuery
. For the standard API, we use the sessionToken
of the current user by default. For the advanced API, you can use any sessionToken
when you subscribe to a MoralisQuery
. An important thing to be aware of is when you log out or the sessionToken
you are using is invalid, you should unsubscribe from the subscription and subscribe to the MoralisQuery
again. Otherwise, you may face a security issue since you'll get events that shouldn't be sent to you.