mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-16 17:23:04 +08:00
31 lines
876 B
C#
31 lines
876 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using MQTTnet.Core.Client;
|
|
using MQTTnet.Core.Packets;
|
|
using MQTTnet.Core.Serializer;
|
|
|
|
namespace MQTTnet.Core.Adapter
|
|
{
|
|
public interface IMqttCommunicationAdapter
|
|
{
|
|
Task ConnectAsync(MqttClientOptions options, TimeSpan timeout);
|
|
|
|
Task DisconnectAsync();
|
|
|
|
Task SendPacketsAsync( TimeSpan timeout, IEnumerable<MqttBasePacket> packets );
|
|
|
|
Task<MqttBasePacket> ReceivePacketAsync(TimeSpan timeout);
|
|
|
|
IMqttPacketSerializer PacketSerializer { get; }
|
|
}
|
|
|
|
public static class IMqttCommunicationAdapterExtensions
|
|
{
|
|
public static Task SendPacketsAsync( this IMqttCommunicationAdapter adapter, TimeSpan timeout, params MqttBasePacket[] packets )
|
|
{
|
|
return adapter.SendPacketsAsync( timeout, packets );
|
|
}
|
|
}
|
|
}
|