Interface ControllerSerializer

All Known Implementing Classes:
DefaultControllerSerializer

public interface ControllerSerializer
This interface provides a standardized way to serialize a session
  • Method Details

    • toSmile

      static ControllerSerializer toSmile()
      Returns the default serializer This implementation uses .smile files compressed using gzip
      Returns:
      a serializer
    • toSmile

      static ControllerSerializer toSmile(Path baseDirectory)
      Returns the default serializer This implementation uses .smile files compressed using gzip
      Parameters:
      baseDirectory - the directory where all the sessions should be saved
      Returns:
      a serializer
    • listIds

      LinkedList<UUID> listIds(ClientType type)
      Returns all the known IDs
      Parameters:
      type - the non-null type of client
      Returns:
      a non-null linked list
    • listPhoneNumbers

      LinkedList<PhoneNumber> listPhoneNumbers(ClientType type)
      Returns all the known IDs
      Parameters:
      type - the non-null type of client
      Returns:
      a non-null linked list
    • newStoreKeysPair

      StoreKeysPair newStoreKeysPair(UUID uuid, Long phoneNumber, Collection<String> alias, ClientType clientType)
      Creates a fresh pair of store and keys
      Parameters:
      uuid - the non-null uuid
      phoneNumber - the nullable phone number
      alias - the nullable alias
      clientType - the non-null client type
      Returns:
      a non-null store-keys pair
    • deserializeStoreKeysPair

      Optional<StoreKeysPair> deserializeStoreKeysPair(UUID uuid, Long phoneNumber, String alias, ClientType clientType)
      Deserializes a store-keys pair from a list of possible identifiers
      Parameters:
      uuid - the nullable identifying unique id
      phoneNumber - the nullable identifying phone number
      alias - the nullable identifying alias
      clientType - the non-null client type
      Returns:
      an optional store-keys pair
    • serializeKeys

      CompletableFuture<Void> serializeKeys(Keys keys, boolean async)
      Serializes the keys
      Parameters:
      keys - the non-null keys to serialize
      async - whether the operation should be executed asynchronously
    • serializeStore

      CompletableFuture<Void> serializeStore(Store store, boolean async)
      Serializes the store
      Parameters:
      store - the non-null store to serialize
      async - whether the operation should be executed asynchronously
    • deserializeKeys

      Optional<Keys> deserializeKeys(ClientType type, UUID id)
      Serializes the keys
      Parameters:
      type - the non-null type of client
      id - the id of the keys
      Returns:
      a non-null keys
    • deserializeKeys

      Optional<Keys> deserializeKeys(ClientType type, long phoneNumber)
      Serializes the keys
      Parameters:
      type - the non-null type of client
      phoneNumber - the phone number of the keys
      Returns:
      a non-null keys
    • deserializeKeys

      Optional<Keys> deserializeKeys(ClientType type, String alias)
      Serializes the keys
      Parameters:
      type - the non-null type of client
      alias - the alias number of the keys
      Returns:
      a non-null keys
    • deserializeStore

      Optional<Store> deserializeStore(ClientType type, UUID id)
      Serializes the store
      Parameters:
      type - the non-null type of client
      id - the id of the store
      Returns:
      a non-null store
    • deserializeStore

      Optional<Store> deserializeStore(ClientType type, long phoneNumber)
      Serializes the store
      Parameters:
      type - the non-null type of client
      phoneNumber - the phone number of the store
      Returns:
      a non-null store
    • deserializeStore

      Optional<Store> deserializeStore(ClientType type, String alias)
      Serializes the store
      Parameters:
      type - the non-null type of client
      alias - the alias of the store
      Returns:
      a non-null store
    • deleteSession

      void deleteSession(Controller<?> controller)
      Deletes a session
      Parameters:
      controller - the non-null controller
    • linkMetadata

      default void linkMetadata(Controller<?> controller)
      Creates a link between the session and its metadata, usually phone number and alias
      Parameters:
      controller - a non-null controller
    • attributeStore

      default CompletableFuture<Void> attributeStore(Store store)
      Attributes the store asynchronously. This method is optionally used to load asynchronously heavy data such as chats while the socket is connecting. If implemented, cache the returning newsletters because the method may be called multiple times.
      Parameters:
      store - the non-null store to attribute
      Returns:
      a completable newsletters