コード例 #1
0
        private void InvokeHandlersForIncomingPublish(PublishPacket message)
        {
            var handler = client.MessageReceivedHandler;

            if (handler != null)
            {
                handler.OnMesage(message.ToMessage());
            }
        }
コード例 #2
0
        private Task ProcessReceivedPublishPacketAsync(PublishPacket publishPacket)
        {
            OnMessageReceived(_options.ClientId, publishPacket.ToMessage());

            switch (publishPacket.Qos)
            {
            case MqttQos.AtMostOnce:
                return(Task.CompletedTask);

            case MqttQos.AtLeastOnce:
                return(SendAsync(new PubAckPacket(publishPacket.PacketId)));

            case MqttQos.ExactlyOnce:
                return(SendAsync(new PubRecPacket(publishPacket.PacketId)));

            default:
                throw new MqttException("Received a not supported QoS level.");
            }
        }