internal static MqttPublishMessage InternalDeserialize(byte[] buffer)
 {
     var msg = new MqttPublishMessage();
     msg._msg.MsgBuffer = buffer;
     msg.ReadVariableHeader();
     return msg;
 }
Example #2
0
        internal static MqttPublishMessage InternalDeserialize(byte[] buffer)
        {
            var msg = new MqttPublishMessage();

            msg._msg.MsgBuffer = buffer;
            msg.ReadVariableHeader();
            return(msg);
        }
 private void FireOnMessage(MqttPublishMessage msg)
 {
     if (OnMessage != null)
     {
         OnMessage(this, new MqttPublishMessageEventArgs
         {
             AdditionalErrorInfo = null,
             Exception = null,
             Message = msg
         });
     }
 }
 /// <summary>
 /// Notify this subscription of a received publish event.
 /// </summary>
 /// <param name="msg"></param>
 /// <returns>True if the subscription handled the event, false otherwise.</returns>
 internal bool NotifyPublishReceived(MqttPublishMessage msg)
 {
     if (Topic.IsTopicMatch(_subscription.TopicName, msg.TopicName) && _callback != null)
     {
         _callback(msg);
         return true;
     }
     return false;
 }
        public static IMqttMessage Deserialize(
#if WIN_PCL
            [ReadOnlyArray]
#endif
            byte[] buffer
            )
        {
            var          msgType      = ReadMessageTypeFromHeader(buffer[0]);
            IMqttMessage resultingMsg = null;

            switch (msgType)
            {
            case MessageType.Connect:
                resultingMsg = MqttConnectMessage.InternalDeserialize(buffer);
                break;

            case MessageType.ConnAck:
                resultingMsg = MqttConnectAckMessage.InternalDeserialize(buffer);
                break;

            case MessageType.Disconnect:
                resultingMsg = MqttDisconnectMessage.InternalDeserialize(buffer);
                break;

            case MessageType.PubAck:
                resultingMsg = MqttPublishAckMessage.InternalDeserialize(buffer);
                break;

            case MessageType.PubRec:
                resultingMsg = MqttPublishReceivedMessage.InternalDeserialize(buffer);
                break;

            case MessageType.PubRel:
                resultingMsg = MqttPublishReleaseMessage.InternalDeserialize(buffer);
                break;

            case MessageType.PubComp:
                resultingMsg = MqttPublishCompleteMessage.InternalDeserialize(buffer);
                break;

            case MessageType.Publish:
                resultingMsg = MqttPublishMessage.InternalDeserialize(buffer);
                break;

            case MessageType.Subscribe:
                resultingMsg = MqttSubscribeMessage.InternalDeserialize(buffer);
                break;

            case MessageType.SubAck:
                resultingMsg = MqttSubscribeAckMessage.InternalDeserialize(buffer);
                break;

            case MessageType.Unsubscribe:
                resultingMsg = MqttUnsubscribeMessage.InternalDeserialize(buffer);
                break;

            case MessageType.UnsubAck:
                resultingMsg = MqttUnsubscribeAckMessage.InternalDeserialize(buffer);
                break;

            case MessageType.PingReq:
                resultingMsg = MqttPingRequestMessage.InternalDeserialize(buffer);
                break;

            case MessageType.PingResp:
                resultingMsg = MqttPingResponseMessage.InternalDeserialize(buffer);
                break;
            }

            return(resultingMsg);
        }
 public IMqttMessage GetMessage()
 {
     byte[] initializedBuffer = _bldr.CreateInitializedMessageBuffer(CalcMessageLength(), PopulateBuffer);
     return(MqttPublishMessage.InternalDeserialize(initializedBuffer));
 }
 internal bool NotifyPublishReceived(MqttPublishMessage msg)
 {
     return false;
 }
 private void NotifyClient(MqttPublishMessage msg)
 {
     FireOnMessage(msg);
 }