- All Known Implementing Classes:
DiscardingControllerSerializer,ProtobufControllerSerializer
public interface ControllerSerializer
This interface provides a standardized way to serialize a session
-
Method Summary
Modifier and TypeMethodDescriptiondefault CompletableFuture<Void> attributeStore(Store store) Attributes the store asynchronously.voiddeleteSession(Controller<?> controller) Deletes a sessiondeserializeKeys(ClientType type, long phoneNumber) Serializes the keysdeserializeKeys(ClientType type, String alias) Serializes the keysdeserializeKeys(ClientType type, UUID id) Serializes the keysdeserializeStore(ClientType type, long phoneNumber) Serializes the storedeserializeStore(ClientType type, String alias) Serializes the storedeserializeStore(ClientType type, UUID id) Serializes the storedefault Optional<StoreKeysPair> deserializeStoreKeysPair(UUID uuid, Long phoneNumber, String alias, ClientType clientType) Deserializes a store-keys pair from a list of possible identifiersstatic ControllerSerializerReturns the default serializer This implementation uses .proto files compressed using gzipdefault voidlinkMetadata(Controller<?> controller) Creates a link between the session and its metadata, usually phone number and aliaslistIds(ClientType type) Returns all the known IDslistPhoneNumbers(ClientType type) Returns all the known IDsdefault StoreKeysPairnewStoreKeysPair(UUID uuid, Long phoneNumber, Collection<String> alias, ClientType clientType) Creates a fresh pair of store and keysserializeKeys(Keys keys, boolean async) Serializes the keysserializeStore(Store store, boolean async) Serializes the storestatic ControllerSerializerReturns the default serializer This implementation uses .proto files compressed using gzipstatic ControllerSerializertoProtobuf(Path baseDirectory) Returns the default serializer This implementation uses .proto files compressed using gzip
-
Method Details
-
discarding
Returns the default serializer This implementation uses .proto files compressed using gzip- Returns:
- a serializer
-
toProtobuf
Returns the default serializer This implementation uses .proto files compressed using gzip- Returns:
- a serializer
-
toProtobuf
Returns the default serializer This implementation uses .proto files compressed using gzip- Parameters:
baseDirectory- the directory where all the sessions should be saved- Returns:
- a serializer
-
listIds
Returns all the known IDs- Parameters:
type- the non-null type of client- Returns:
- a non-null linked list
-
listPhoneNumbers
Returns all the known IDs- Parameters:
type- the non-null type of client- Returns:
- a non-null linked list
-
newStoreKeysPair
default StoreKeysPair newStoreKeysPair(UUID uuid, Long phoneNumber, Collection<String> alias, ClientType clientType) Creates a fresh pair of store and keys- Parameters:
uuid- the non-null uuidphoneNumber- the nullable phone numberalias- the nullable aliasclientType- the non-null client type- Returns:
- a non-null store-keys pair
-
deserializeStoreKeysPair
default 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 idphoneNumber- the nullable identifying phone numberalias- the nullable identifying aliasclientType- the non-null client type- Returns:
- an optional store-keys pair
-
serializeKeys
Serializes the keys- Parameters:
keys- the non-null keys to serializeasync- whether the operation should be executed asynchronously
-
serializeStore
Serializes the store- Parameters:
store- the non-null store to serializeasync- whether the operation should be executed asynchronously
-
deserializeKeys
Serializes the keys- Parameters:
type- the non-null type of clientid- the id of the keys- Returns:
- a non-null keys
-
deserializeKeys
Serializes the keys- Parameters:
type- the non-null type of clientphoneNumber- the phone number of the keys- Returns:
- a non-null keys
-
deserializeKeys
Serializes the keys- Parameters:
type- the non-null type of clientalias- the alias number of the keys- Returns:
- a non-null keys
-
deserializeStore
Serializes the store- Parameters:
type- the non-null type of clientid- the id of the store- Returns:
- a non-null store
-
deserializeStore
Serializes the store- Parameters:
type- the non-null type of clientphoneNumber- the phone number of the store- Returns:
- a non-null store
-
deserializeStore
Serializes the store- Parameters:
type- the non-null type of clientalias- the alias of the store- Returns:
- a non-null store
-
deleteSession
Deletes a session- Parameters:
controller- the non-null controller
-
linkMetadata
Creates a link between the session and its metadata, usually phone number and alias- Parameters:
controller- a non-null controller
-
attributeStore
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
-