private void HandlePUBLISHType(MqttMsgPublish publish) { try { switch (publish.QosLevel) { case MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE: { CrestronLogger.WriteToLog("MQTTCLIENT - HandlePUBLISHType - Routing qos0 message", 5); string publishPayload = System.Text.Encoding.ASCII.GetString(publish.Message, 0, publish.Message.Length); OnMessageArrived(publish.Topic, PayloadMapper.Map(publishPayload)); break; } case MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE: { CrestronLogger.WriteToLog("MQTTCLIENT - HandlePUBLISHType - Routing qos1 message", 5); string publishPayload = System.Text.Encoding.ASCII.GetString(publish.Message, 0, publish.Message.Length); Send(MsgBuilder.BuildPubAck(publish.MessageId)); OnMessageArrived(publish.Topic, PayloadMapper.Map(publishPayload)); break; } case MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE: { CrestronLogger.WriteToLog("MQTTCLIENT - HandlePUBLISHType - Routing qos2 message", 5); //ManageQoS2(publish); break; } default: break; } //TODO: Raise MessageArrived event , handle the necessary responses with the publisher manager. } catch (ArgumentException e) { OnErrorOccured(e.Message); } }