MessageOut Event
Fired when an outgoing message has been sent and/or fully acknowledged.
Syntax
ANSI (Cross Platform) virtual int FireMessageOut(MQTTMessageOutEventParams *e);
typedef struct {
int PacketId;
const char *Topic;
int QOS;
const char *Message; int lenMessage;
int Retained;
int Duplicate; int reserved; } MQTTMessageOutEventParams; Unicode (Windows) virtual INT FireMessageOut(MQTTMessageOutEventParams *e);
typedef struct {
INT PacketId;
LPCWSTR Topic;
INT QOS;
LPCSTR Message; INT lenMessage;
BOOL Retained;
BOOL Duplicate; INT reserved; } MQTTMessageOutEventParams;
- (void)onMessageOut:(int)packetId :(NSString*)topic :(int)QOS :(NSData*)message :(BOOL)retained :(BOOL)duplicate;
#define EID_MQTT_MESSAGEOUT 8 virtual INT IPWORKSMQ_CALL FireMessageOut(INT &iPacketId, LPSTR &lpszTopic, INT &iQOS, LPSTR &lpMessage, INT &lenMessage, BOOL &bRetained, BOOL &bDuplicate);
Remarks
The MessageOut event fires once for each outgoing message either immediately after it is sent (QoS 0), or after it has been fully acknowledged by the receiver (QoS 1 and 2).
- PacketId: The message packet Id. This will always be -1 if QOS is 0.
- Topic: The message's topic string.
- QOS: The message's QoS level.
- Message: The message data.
- Retained: Whether or not this message was sent with the "Retain" flag set.
- Duplicate: Whether or not this message was sent with the "Duplicate" flag set.
Refer to MessageAck for more information about QoS 1 and 2 message processing steps.
// MessageOut event handler.
mqtt1.OnMessageOut += (s, e) => {
Console.WriteLine("Send message to topic '" + e.Topic + "' with QoS " + e.QOS + ":");
Console.WriteLine(e.Message);
};