MessageIn Event
Fired when an incoming message has been received and/or fully acknowledged.
Syntax
class MQTTSNMessageInEventParams { public: int MsgId(); const QString &TopicId(); int TopicIdType(); int QOS(); const QByteArray &Message(); bool Retained(); bool Duplicate(); int ReturnCode(); void SetReturnCode(int iReturnCode); int EventRetVal(); void SetEventRetVal(int iRetVal); };
// To handle, connect one or more slots to this signal. void MessageIn(MQTTSNMessageInEventParams *e);
// Or, subclass MQTTSN and override this emitter function. virtual int FireMessageIn(MQTTSNMessageInEventParams *e) {...}
Remarks
Fired on reception of a PUBLISH packet for QoS 0 and 1 messages, and reception of a PUBREL packet for QoS 2 messages.
- MsgId: a unique (among currently unacknowledged incoming messages) identifier attached to messages of QoS 1 and 2. Otherwise value will be 0.
- TopicId: topic id of type TopicIdType.
- TopicIdType: 0 = registered topic id, 1 = pre-defined topic id, 2 = short topic name.
- QOS: The message's QoS level.
- Message: The message data.
- Retained: Whether or not this message was received as a result of subscribing to a topic.
- Duplicate: Whether or not the server has indicated that this message is a duplicate of another message sent previously.
- ReturnCode: QoS 1 messages can be accepted or rejected by setting the ReturnCode to a value listed below.
- 0: accepted
- 1: rejected - congestion
- 2: rejected - invalid topic id
- 3: rejected - not supported
Inbound Message Processing
Incoming messages with a QoS of 1 follow these steps:
- The TopicInfo event is fired (if the gateway sends a REGISTER packet because it needs to inform the client name and assigned topic id it will use in a PUBLISH message).
- The class sends a REGACK (register acknowledgment) packet in response (if a REGISTER packet was received).
- The MessageIn event is fired.
- The class sends a PUBACK (publish acknowledgment) packet in response (with the return code from the MessageIn event if one is set).
Incoming messages with a QoS of 2 follow these steps:
- The TopicInfo event is fired (if the gateway sends a REGISTER packet because it needs to inform the client name and assigned topic id it will use in a PUBLISH message).
- The class sends a REGACK (register acknowledgment) packet in response (if a REGISTER packet was received).
- The class sends a PUBREC (publish received) packet in response.
- The class waits to receive a PUBREL (publish release) packet.
- The class sends a PUBCOMP (publish complete) packet in response.
- The MessageIn event is fired.