Class Messenger
#include <Messenger.h >
Class to handle MAE (one-way) messages between MAE apps.
Messages are routed by MsgBroker.
This class works in conjunction with the MAETask class, which maintains the connection to CommHub, which is required to reach the MsgBroker daemon.
The MAE class class sets up message channels for your app and code generated by genmae uses this class to send messages.
Constructor. Connects to app MAETask class instance.
By default, sent messages will be sent on the task's first registered channel.
const string& dest |
the name of the channel to send this message to |
const string& request |
the message type or name of the request being sent (a keyword) |
const XMLData& data |
the data/payload of the message. You should make sure it is compatbile with the app that is receiving the request to make sure they key-value pairs in the payload can be processed by the receiving app |
Send a message
Return value: true if message sent
const string& channel |
the unique channel name for listening (this is is registered with MsgBroker) |
bool persist |
true if MsgBroker should queue up messages to this channel even when the channel is off-line |
MessengerFN cbfn |
specify the message handler that will process the messages, typically handleMessage() |
MAE calls this for your app; your app should not call it.
Start listening to a channel.
(Only listen to one channel per instance of Messenger)
Return name of this channel
Return value: the name of the current channel
const string& channel |
the Messenger channel to find. |
Get Messenger instance of channel
Return value: the instance Messenger registered to the named channel
Get list of all channels open for listening
Return value: a list of all registered channels
const string& dest |
the name of the channel to send this message to |
const string& errorMessage |
the message to send to the destination channel |
Send an error back to the calling app
Return value: true if message sent
Close the current channel.
Return value: true
Close all open channels.
Close a persistent channel. MsgBroker will stop queuing messages for this channel.
Get last status message sent by MsgBroker.
Return value: the current status of the channel
Clear last status message from MsgBroker.
const string& source |
a channel name to check |
Check if a message came from the system administrator
Return value: true if source came from the Supervisor app.
string channel |
the message channel for this instance |
MessengerFN cbfn |
the callback function to handle inbound messages for this channel |
string status |
the status of this channel |
static vector <Messenger* list |
all message channels used by this app |
SuperSocket& sock |
the socket for communication with commhub |
const string& text |
the message to handle |
void* data |
callback data |
Master callback handler for inbound messages