You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

31 line
876 B

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading.Tasks;
  4. using MQTTnet.Core.Client;
  5. using MQTTnet.Core.Packets;
  6. using MQTTnet.Core.Serializer;
  7. namespace MQTTnet.Core.Adapter
  8. {
  9. public interface IMqttCommunicationAdapter
  10. {
  11. Task ConnectAsync(MqttClientOptions options, TimeSpan timeout);
  12. Task DisconnectAsync();
  13. Task SendPacketsAsync( TimeSpan timeout, IEnumerable<MqttBasePacket> packets );
  14. Task<MqttBasePacket> ReceivePacketAsync(TimeSpan timeout);
  15. IMqttPacketSerializer PacketSerializer { get; }
  16. }
  17. public static class IMqttCommunicationAdapterExtensions
  18. {
  19. public static Task SendPacketsAsync( this IMqttCommunicationAdapter adapter, TimeSpan timeout, params MqttBasePacket[] packets )
  20. {
  21. return adapter.SendPacketsAsync( timeout, packets );
  22. }
  23. }
  24. }