The ActionDispatcher is used to dispatch inbound messages and forward them to their corresponding [Action Handler].
More...
#include "ActionDispatcher.h"
|
void | add (ActionHandleConnectorBase *_handler, bool _overwrite=false) |
| Add the provided [handler] to this ActionDispatcher. The handler will be used for all specified actions.
|
|
void | remove (ActionHandleConnectorBase *_handler) |
|
char * | dispatchWrapper (const char *_json, const char *_senderUrl, ot::MessageType _messageType) |
| This function may be called from the main external API that is receiving the perform/ queue messages This function will forward the call to the dispatch function and will create a C-String copy of the result so the string can be directy returned out of the dll/application.
|
|
std::string | dispatch (const std::string &_json, ot::MessageType _messageType) |
| Will get and forward the action to all registered handlers.
|
|
std::string | dispatch (JsonDocument &_document, MessageType _messageType) |
| Will get and forward the action to all registered handlers.
|
|
std::string | dispatch (const std::string &_action, JsonDocument &_document, ot::MessageType _messageType) |
| Will forward the action to all registered handlers Will return the result of the last handler Uses a mutex to ensure that only one request is handled at a time.
|
|
std::string | dispatch (const std::string &_action, JsonDocument &_document, bool &_handlerFound, ot::MessageType _messageType) |
| Will forward the action to all registered handlers Will return the result of the last handler Uses a mutex to ensure that only one request is handled at a time.
|
|
std::string | dispatchLocked (const std::string &_action, JsonDocument &_document, bool &_handlerFound, ot::MessageType _messageType) |
| The actual dispatcher method. Here it is assumed that the mutex is already locked.
|
|
The ActionDispatcher is used to dispatch inbound messages and forward them to their corresponding [Action Handler].
◆ add()
Add the provided [handler] to this ActionDispatcher. The handler will be used for all specified actions.
- Note
- If another [handler] already registered for one of the actions, the action will be ignored if "_overwrite" is false and a warning log message is generated.
- Parameters
-
_handler | New handler to add for all actions set in the [handler]. |
_overwrite | If true, a existing handler will be removed if the provided handler requests the same action. |
◆ dispatch() [1/4]
std::string ot::ActionDispatcher::dispatch |
( |
const std::string & | _action, |
|
|
JsonDocument & | _document, |
|
|
bool & | _handlerFound, |
|
|
ot::MessageType | _messageType ) |
Will forward the action to all registered handlers Will return the result of the last handler Uses a mutex to ensure that only one request is handled at a time.
- Parameters
-
_action | The action to dispatch |
_document | The document containing the action parameter |
_handlerFound | Will be set to true if at least one handler was found to dispatch this action to |
◆ dispatch() [2/4]
Will forward the action to all registered handlers Will return the result of the last handler Uses a mutex to ensure that only one request is handled at a time.
- Parameters
-
_action | The action to dispatch |
_document | The document containing the action parameter |
◆ dispatch() [3/4]
std::string ot::ActionDispatcher::dispatch |
( |
const std::string & | _json, |
|
|
ot::MessageType | _messageType ) |
Will get and forward the action to all registered handlers.
◆ dispatch() [4/4]
Will get and forward the action to all registered handlers.
◆ dispatchLocked()
std::string ot::ActionDispatcher::dispatchLocked |
( |
const std::string & | _action, |
|
|
JsonDocument & | _document, |
|
|
bool & | _handlerFound, |
|
|
ot::MessageType | _messageType ) |
The actual dispatcher method. Here it is assumed that the mutex is already locked.
- Note
- Unsafe, only call from a handler when the mutex is already locked! Will return the result of the last handler. The mutex is not used at this place.
- Parameters
-
_action | The action to dispatch. |
_document | The document containing the action parameter. |
_handlerFound | Will be set to true if at least one handler was found to dispatch this action to. |
◆ dispatchWrapper()
char * ot::ActionDispatcher::dispatchWrapper |
( |
const char * | _json, |
|
|
const char * | _senderUrl, |
|
|
ot::MessageType | _messageType ) |
This function may be called from the main external API that is receiving the perform/ queue messages This function will forward the call to the dispatch function and will create a C-String copy of the result so the string can be directy returned out of the dll/application.
◆ instance()
return ot::ActionDispatcher::instance |
( |
void | | ) |
|
|
static |
Returns the clobal singleton instance.
◆ remove()
◆ ~ActionDispatcher()
ot::ActionDispatcher::~ActionDispatcher |
( |
| ) |
|
|
privatevirtual |
The documentation for this class was generated from the following files: