disconnectUser method

Future<void> disconnectUser({
  1. bool flushChatPersistence = false,
})

Closes the _ws connection and resets the state If flushChatPersistence is true the client deletes all offline user's data.

Implementation

Future<void> disconnectUser({bool flushChatPersistence = false}) async {
  logger.info('Disconnecting user : ${state.currentUser?.id}');

  // resetting state.
  state.dispose();
  state = ClientState(this);
  _lastSyncedAt = null;

  // resetting credentials.
  _tokenManager.reset();
  _connectionIdManager.reset();

  // closing persistence connection.
  await closePersistenceConnection(flush: flushChatPersistence);

  // closing web-socket connection
  return closeConnection();
}