Typically used together with CustomMsgServerDelegate e.g. to ensure a matching interface. Subclasses represent a custom server.
More...
#include <objectbox-sync.hpp>
|
| AbstractCustomMsgServer (const uint64_t id) |
|
virtual | ~AbstractCustomMsgServer ()=default |
|
uint64_t | id () const |
| ID for this server instance (was passed via the constructor). More...
|
|
virtual uint64_t | start ()=0 |
| The custom server shall do any preparations to start (to be implemented by concrete subclass). The implementation may throw an exception to signal that starting was not successful; note that exception specifics are ignored, e.g. the type and any exception message. More...
|
|
virtual void | stop ()=0 |
| The custom server 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 shutdown() for this. More...
|
|
virtual void | shutdown ()=0 |
| The custom server shall do any preparations to shut down (to be implemented by concrete subclass). Ensure that everything is ready for the custom server to be destroyed: the custom server will be deleted right after this call (by the CustomMsgServerDelegate). More...
|
|
uint64_t | addConnection (const std::shared_ptr< AbstractCustomMsgConnection > &connection) |
| Must be called from the custom server when a new client connection becomes available. If successful, the ID is also set at the given connection. More...
|
|
bool | removeConnection (uint64_t connectionId) |
| Must be called from the custom server when a client connection becomes inactive (e.g. closed) and can be removed. More...
|
|
bool | removeConnection (const AbstractCustomMsgConnection &connection) |
| Short hand for removeConnection(connection.id()). More...
|
|
bool | forwardReceivedMessageFromClient (uint64_t connectionId, const void *messageData, size_t messageSize) |
| The custom msg server must call this whenever a message is received from a client connection. More...
|
|
Typically used together with CustomMsgServerDelegate e.g. to ensure a matching interface. Subclasses represent a custom server.
- 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.
◆ AbstractCustomMsgServer()
obx::AbstractCustomMsgServer::AbstractCustomMsgServer |
( |
const uint64_t |
id | ) |
|
|
inlineexplicit |
◆ ~AbstractCustomMsgServer()
virtual obx::AbstractCustomMsgServer::~AbstractCustomMsgServer |
( |
| ) |
|
|
virtualdefault |
◆ addConnection()
Must be called from the custom server when a new client connection becomes available. If successful, the ID is also set at the given connection.
- Parameters
-
connection | will be held internally as a weak ptr, so it should affect its lifetime only mildly. Only when a callback is delegated, it will have hold a strong (shared_ptr) reference for that time. |
- Returns
- client connection ID (never 0; also set at the given connection)
- Exceptions
-
Exception | in case the operation encountered an exceptional issue |
◆ forwardReceivedMessageFromClient()
bool obx::AbstractCustomMsgServer::forwardReceivedMessageFromClient |
( |
uint64_t |
connectionId, |
|
|
const void * |
messageData, |
|
|
size_t |
messageSize |
|
) |
| |
|
inline |
The custom msg server must call this whenever a message is received from a client connection.
- Parameters
-
connectionId | ID of the connection the messages originated from. |
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.
- Exceptions
-
Exception | in case the operation encountered an exceptional issue |
◆ id()
uint64_t obx::AbstractCustomMsgServer::id |
( |
| ) |
const |
|
inline |
ID for this server instance (was passed via the constructor).
◆ removeConnection() [1/2]
Short hand for removeConnection(connection.id()).
◆ removeConnection() [2/2]
bool obx::AbstractCustomMsgServer::removeConnection |
( |
uint64_t |
connectionId | ) |
|
|
inline |
Must be called from the custom server when a client connection becomes inactive (e.g. closed) and can be removed.
- Parameters
-
connectionId | ID of the connection the messages originated from. |
- Returns
- true if the given message could be forwarded.
-
false in case the operation encountered an issue.
- Exceptions
-
Exception | in case the operation encountered an exceptional issue |
◆ shutdown()
virtual void obx::AbstractCustomMsgServer::shutdown |
( |
| ) |
|
|
pure virtual |
The custom server shall do any preparations to shut down (to be implemented by concrete subclass). Ensure that everything is ready for the custom server to be destroyed: the custom server will be deleted right after this call (by the CustomMsgServerDelegate).
◆ start()
virtual uint64_t obx::AbstractCustomMsgServer::start |
( |
| ) |
|
|
pure virtual |
The custom server shall do any preparations to start (to be implemented by concrete subclass). The implementation may throw an exception to signal that starting was not successful; note that exception specifics are ignored, e.g. the type and any exception message.
- Returns
- The custom server can optionally supply a "port"; the value is arbitrary and, for now, is only used for debug logs.
◆ stop()
virtual void obx::AbstractCustomMsgServer::stop |
( |
| ) |
|
|
pure virtual |
The custom server 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 shutdown() for this.