Message Event (Received messages)

Private Sub mClient_ApplicationMessage(ByVal msgEvent As MQTTMessageEvent) On Error GoTo errExit Dim payloadText As String Dim i As Integer payloadText = msgEvent.Message.PayloadAsText MsgBox msgEvent.Message.Topic + ": " + payloadText 'Get more advanced MQTT properties from payload Dim subIDsText As String Dim subIDs() As Long If VarType(msgEvent.Message.SubscriptionIdentifiers) <> Empty Then subIDs = msgEvent.Message.SubscriptionIdentifiers For i = LBound(subIDs) To UBound(subIDs) subIDsText = subIDsText & CStr(subIDs(i)) Next i End If Dim corrDataText As String If VarType(msgEvent.Message.Correlation) <> Empty Then corrDataText = StrConv(msgEvent.Message.Correlation, vbUnicode) End If Dim userPropsText As String Dim userProps() As MQTTUserProperty If VarType(msgEvent.Message.UserProperties) <> Empty Then userProps = msgEvent.Message.UserProperties For i = LBound(userProps) To UBound(userProps) userPropsText = userPropsText + userProps(i).Name + ":" + userProps(i).Value Next End If MsgBox CStr(msgEvent.Message.QoS) + CStr(msgEvent.Message.Retain) + CStr(msgEvent.Message.MessageExpiryInterval) + CStr(msgEvent.Message.PayloadFormat) + msgEvent.Message.ContentType + subIDsText + msgEvent.Message.ResponseTopic + corrDataText + userPropsText Exit Sub errExit: MsgBox err.Description End Sub
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal