Typically used together with CustomMsgClientDelegate e.g. to ensure a matching interface. Subclasses represent a custom client.
More...
#include <objectbox-sync.hpp>
|
| AbstractCustomMsgClient (uint64_t id) |
|
virtual | ~AbstractCustomMsgClient ()=default |
|
uint64_t | id () const |
| ID for this client instance (was passed via the constructor).
|
|
virtual void | start ()=0 |
| Tells the client to prepare for starting (to be implemented by concrete subclass).
|
|
virtual void | stop ()=0 |
| The custom client shall do any preparations to stop (to be implemented by concrete subclass). E.g. signal asynchronous resources (e.g. threads, async IO, ...) to stop. Note that there's no need to wait for asynchronous resources here; better use join() for this.
|
|
virtual void | join ()=0 |
| Called after stop() to wait for asynchronous resources here (e.g. join any spawned threads).
|
|
virtual void | shutdown ()=0 |
| The custom client shall do any preparations to shut down (to be implemented by concrete subclass). Ensure that everything is ready for the custom client to be destroyed: the custom client will be deleted right after this call (by the CustomMsgClientDelegate).
|
|
virtual bool | connect ()=0 |
| Tells the client it shall start trying to connect (to be implemented by concrete subclass).
|
|
virtual void | disconnect (bool clearOutgoingMessages)=0 |
| Tells the client it shall disconnect (to be implemented by concrete subclass).
|
|
virtual bool | sendAsync (BytesLazy &&message)=0 |
| Enqueue a message for sending (to be implemented by concrete subclass).
|
|
virtual void | clearOutgoingMessages ()=0 |
| Clear all outgoing messages (to be implemented by concrete subclass).
|
|
bool | forwardReceivedMessageFromServer (const void *messageData, size_t messageSize) |
| The custom msg client must call this whenever a message is received from the server.
|
|
bool | forwardState (OBXCustomMsgClientState state) |
| The custom msg client must call this whenever the state (according to given enum values) changes.
|
|
bool | triggerReconnect () |
| The custom msg client may call this if it has knowledge when a reconnection attempt makes sense, for example, when the network becomes available.
|
|
Typically used together with CustomMsgClientDelegate e.g. to ensure a matching interface. Subclasses represent a custom client.
- Note
- At this point, the overridden methods must not throw unless specified otherwise.
-
All virtual methods are pure virtual; no default implementation (e.g. {}) is provided to ensure the implementor is aware of all the interactions and thus shall explicitly provide at least empty implementations.
◆ AbstractCustomMsgClient()
obx::AbstractCustomMsgClient::AbstractCustomMsgClient |
( |
uint64_t |
id | ) |
|
|
inlineexplicit |
◆ ~AbstractCustomMsgClient()
virtual obx::AbstractCustomMsgClient::~AbstractCustomMsgClient |
( |
| ) |
|
|
virtualdefault |
◆ clearOutgoingMessages()
virtual void obx::AbstractCustomMsgClient::clearOutgoingMessages |
( |
| ) |
|
|
pure virtual |
Clear all outgoing messages (to be implemented by concrete subclass).
◆ connect()
virtual bool obx::AbstractCustomMsgClient::connect |
( |
| ) |
|
|
pure virtual |
Tells the client it shall start trying to connect (to be implemented by concrete subclass).
- Returns
- true if the operation was successful.
-
false in case the operation encountered an issue.
◆ disconnect()
virtual void obx::AbstractCustomMsgClient::disconnect |
( |
bool |
clearOutgoingMessages | ) |
|
|
pure virtual |
Tells the client it shall disconnect (to be implemented by concrete subclass).
- Parameters
-
◆ forwardReceivedMessageFromServer()
bool obx::AbstractCustomMsgClient::forwardReceivedMessageFromServer |
( |
const void * |
messageData, |
|
|
size_t |
messageSize |
|
) |
| |
|
inline |
The custom msg client must call this whenever a message is received from the server.
- Parameters
-
messageData | the message bytes. |
messageSize | the number of message bytes. |
- Returns
- true if the given message could be forwarded.
-
false in case the operation encountered an issue.
◆ forwardState()
The custom msg client must call this whenever the state (according to given enum values) changes.
- Parameters
-
state | The state to forward |
- Returns
- true if the client was in a state that allowed the transition to the given state.
-
false if no state transition was possible from the current to the given state (e.g. an internal "closed" state was reached).
◆ id()
uint64_t obx::AbstractCustomMsgClient::id |
( |
| ) |
const |
|
inline |
ID for this client instance (was passed via the constructor).
◆ join()
virtual void obx::AbstractCustomMsgClient::join |
( |
| ) |
|
|
pure virtual |
Called after stop() to wait for asynchronous resources here (e.g. join any spawned threads).
◆ sendAsync()
virtual bool obx::AbstractCustomMsgClient::sendAsync |
( |
BytesLazy && |
message | ) |
|
|
pure virtual |
Enqueue a message for sending (to be implemented by concrete subclass).
- Parameters
-
message | the message bytes. |
- Returns
- true if the process of async sending was initiated (e.g. enqueued for processing).
-
false if no attempt of sending data will be made (e.g. connection was already closed).
◆ shutdown()
virtual void obx::AbstractCustomMsgClient::shutdown |
( |
| ) |
|
|
pure virtual |
The custom client shall do any preparations to shut down (to be implemented by concrete subclass). Ensure that everything is ready for the custom client to be destroyed: the custom client will be deleted right after this call (by the CustomMsgClientDelegate).
◆ start()
virtual void obx::AbstractCustomMsgClient::start |
( |
| ) |
|
|
pure virtual |
Tells the client to prepare for starting (to be implemented by concrete subclass).
◆ stop()
virtual void obx::AbstractCustomMsgClient::stop |
( |
| ) |
|
|
pure virtual |
The custom client shall do any preparations to stop (to be implemented by concrete subclass). E.g. signal asynchronous resources (e.g. threads, async IO, ...) to stop. Note that there's no need to wait for asynchronous resources here; better use join() for this.
◆ triggerReconnect()
bool obx::AbstractCustomMsgClient::triggerReconnect |
( |
| ) |
|
|
inline |
The custom msg client may call this if it has knowledge when a reconnection attempt makes sense, for example, when the network becomes available.
- Returns
- true if a reconnect was actually triggered and false otherwise.