Disconnects and Reconnects

A client is disconnected when they lose internet connection or unable to reach the Sync server. When this happens the sdk keeps trying to reconnect to the server.

Handle disconnection

To get notified when a client is disconnected, call the onDisconnect() method of the Hamoni object.

hamoni.onDisconnect(() => console.log("client disconnected") )

Each time a client disconnects that function will be called.

Swift SDK coming soon

Java SDK coming soon

Handle reconnection

When successfully reconnected, the client can be notified through the onReconnect() method of the Hamoni object. Call onReconnect() with a function parameter and that function will be executed each time a client reconnects.

hamoni.onReconnect(() => console.log("client reconnected") )

Swift SDK coming soon

Java SDK coming soon

State Synchronisation

When a client reconnects, the sdk retrieves the latest state from the server and updates the local state. You won't be notified of this update using the onUpdated() method (or it's equivalent) of a state primitive object. Rather, you will use the onSync() method.

  .then(primitive => {
    primitive.onSync( state => console.log(state))
  .catch(error => console.log(error));

The callback receives the latest state as parameter.

Swift SDK coming soon

Java SDK coming soon

results matching ""

    No results matching ""