コード例 #1
0
ファイル: MqttClient.cs プロジェクト: ztittle/MQTTnet
        private async Task <TResponsePacket> SendAndReceiveAsync <TResponsePacket>(MqttBasePacket requestPacket) where TResponsePacket : MqttBasePacket
        {
            var packetAwaiter = _packetDispatcher.WaitForPacketAsync(requestPacket, typeof(TResponsePacket), _options.CommunicationTimeout);
            await _adapter.SendPacketsAsync(_options.CommunicationTimeout, _cancellationTokenSource.Token, requestPacket).ConfigureAwait(false);

            return((TResponsePacket)await packetAwaiter.ConfigureAwait(false));
        }
コード例 #2
0
        private async Task <TResponsePacket> SendAndReceiveAsync <TResponsePacket>(MqttBasePacket requestPacket) where TResponsePacket : MqttBasePacket
        {
            ushort identifier = 0;

            if (requestPacket is IMqttPacketWithIdentifier requestPacketWithIdentifier)
            {
                identifier = requestPacketWithIdentifier.PacketIdentifier;
            }

            var packetAwaiter = _packetDispatcher.WaitForPacketAsync(typeof(TResponsePacket), identifier, _options.CommunicationTimeout);
            await _adapter.SendPacketsAsync(_options.CommunicationTimeout, _cancellationTokenSource.Token, requestPacket).ConfigureAwait(false);

            return((TResponsePacket)await packetAwaiter.ConfigureAwait(false));
        }
コード例 #3
0
        private async Task <TResponsePacket> SendAndReceiveAsync <TResponsePacket>(MqttBasePacket requestPacket) where TResponsePacket : MqttBasePacket
        {
            ushort?identifier = null;

            if (requestPacket is IMqttPacketWithIdentifier requestPacketWithIdentifier)
            {
                identifier = requestPacketWithIdentifier.PacketIdentifier;
            }

            var packetAwaiter = _packetDispatcher.WaitForPacketAsync(typeof(TResponsePacket), identifier, _options.CommunicationTimeout);

            await SendAsync(requestPacket).ConfigureAwait(false);

            return((TResponsePacket)await packetAwaiter.ConfigureAwait(false));
        }