예제 #1
0
        public Task EnqueueApplicationMessageAsync(MqttApplicationMessage applicationMessage)
        {
            if (applicationMessage == null)
            {
                throw new ArgumentNullException(nameof(applicationMessage));
            }

            var publishPacketFactory = new MqttPublishPacketFactory();

            _session.EnqueuePacket(new MqttPacketBusItem(publishPacketFactory.Create(applicationMessage)));

            return(PlatformAbstractionLayer.CompletedTask);
        }
예제 #2
0
        public Task DeliverApplicationMessageAsync(MqttApplicationMessage applicationMessage)
        {
            if (applicationMessage == null)
            {
                throw new ArgumentNullException(nameof(applicationMessage));
            }

            var publishPacketFactory = new MqttPublishPacketFactory();
            var packetBusItem        = new MqttPacketBusItem(publishPacketFactory.Create(applicationMessage));

            _session.EnqueuePacket(packetBusItem);

            return(packetBusItem.WaitForDeliveryAsync());
        }