Cogs.Core
|
A MessageHub that only supports sending messages. More...
#include <MessageHub.h>
Public Member Functions | |
SendOnlyMessageHub (uint32_t ident=0) | |
virtual bool | isSendOnly () const override |
![]() | |
MessageHub (uint32_t ident=0) | |
Constructs a new MessageHub instance and adds it to the global hub list. | |
virtual | ~MessageHub () |
Removes this MessageHub from the global list and cleans up all connections to and from this hub. | |
bool | addListener (MessageHub *hub, bool bidirectional=false) |
Adds the specified hub as a listener to this hub. | |
bool | addListener (uint32_t hubid, bool bidirectional=false) |
Attempts to add the hub with the given ID as a listener to this hub. | |
bool | listenTo (MessageHub *hub, bool bidirectional=false) |
Sets this MessageHub up to listen for messages from the specified hub. | |
bool | listenTo (uint32_t hubid, bool bidirectional=false) |
Sets up this MessageHub to listen for messages from the hub with the specified ID (if a matching hub can be found). | |
bool | removeListener (MessageHub *hub) |
Removes the specified hub as a listener to this hub. | |
bool | removeListener (uint32_t hubid) |
Removes the hub with the given ID as a listener to this hub. | |
void | removeAllListeners () |
Removes all listeners from this hub. | |
void | disconnectFromSender (uint32_t hubid) |
Disconnects this hub from the specified hub to which it is listening. | |
void | disconnectFromAllSenders () |
Disconnects this hub from all hubs to which it is listening. | |
virtual void | broadcastMessage (const Message::Ptr &message) |
Broadcast message to all hubs. | |
virtual void | sendMessage (const Message::Ptr &message) |
Send message to all hubs listening to this one. | |
virtual void | queueMessage (const Message::Ptr &message) |
Queue a message for this hub to process. | |
virtual bool | processMessages (size_t limit=noLimit) |
Process all queued messages for this hub. | |
virtual bool | isSendOnly () const |
uint32_t | getID () const |
size_t | getNoOfQueuedMessages () |
Retrieves the number of messages currently awaiting processing by this hub. | |
void | flushQueuedMessages () |
Flushes all pending messages from this hub without processing them. | |
Private Member Functions | |
virtual void | queueMessage (const Message::Ptr &) override |
Queue a message for this hub to process. | |
Additional Inherited Members | |
![]() | |
using | MessageQueue = std::deque< Message::Ptr > |
using | HubList = std::vector< MessageHub * > |
![]() | |
static constexpr size_t | noLimit = 10000000 |
![]() | |
Message::Ptr | getNextMessage () |
Retrieves the next pending message. | |
A MessageHub that only supports sending messages.
This is a convenience class for when you only need to send messages and do not need to process incoming messages.
Definition at line 83 of file MessageHub.h.
|
inline |
Definition at line 85 of file MessageHub.h.
|
inlineoverridevirtual |
Reimplemented from Cogs::Network::MessageHub.
Definition at line 86 of file MessageHub.h.
|
inlineoverrideprivatevirtual |
Queue a message for this hub to process.
Directly add the specified message to the incoming queue of this hub.
Normally messages are sent from a hub to all its listeners using the sendMessage function. This function, however, allows you to directly input a message into the queue of a single hub. *============================================================================================
Reimplemented from Cogs::Network::MessageHub.
Definition at line 89 of file MessageHub.h.