mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-27 00:40:01 +08:00
Refactor package object model.
This commit is contained in:
@@ -6,7 +6,9 @@ using MQTTnet.Server;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MQTTnet.LowLevelClient;
|
||||
|
||||
namespace MQTTnet.Tests.Mockups
|
||||
{
|
||||
@@ -100,6 +102,25 @@ namespace MQTTnet.Tests.Mockups
|
||||
return ConnectClientAsync(new MqttClientOptionsBuilder());
|
||||
}
|
||||
|
||||
public Task<ILowLevelMqttClient> ConnectLowLevelClientAsync()
|
||||
{
|
||||
return ConnectLowLevelClientAsync(o => {});
|
||||
}
|
||||
|
||||
public async Task<ILowLevelMqttClient> ConnectLowLevelClientAsync(Action<MqttClientOptionsBuilder> optionsBuilder)
|
||||
{
|
||||
if (optionsBuilder == null) throw new ArgumentNullException(nameof(optionsBuilder));
|
||||
|
||||
var options = new MqttClientOptionsBuilder();
|
||||
options = options.WithTcpServer("127.0.0.1", ServerPort);
|
||||
optionsBuilder.Invoke(options);
|
||||
|
||||
var client = new MqttFactory().CreateLowLevelMqttClient();
|
||||
await client.ConnectAsync(options.Build(), CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
public async Task<IMqttClient> ConnectClientAsync(MqttClientOptionsBuilder options)
|
||||
{
|
||||
if (options == null) throw new ArgumentNullException(nameof(options));
|
||||
@@ -111,7 +132,7 @@ namespace MQTTnet.Tests.Mockups
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
|
||||
public async Task<IMqttClient> ConnectClientAsync(IMqttClientOptions options)
|
||||
{
|
||||
if (options == null) throw new ArgumentNullException(nameof(options));
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace MQTTnet.Tests.Mockups
|
||||
{
|
||||
public class TestMqttCommunicationAdapter : IMqttChannelAdapter
|
||||
{
|
||||
private readonly BlockingCollection<MqttBasePacket> _incomingPackets = new BlockingCollection<MqttBasePacket>();
|
||||
readonly BlockingCollection<MqttBasePacket> _incomingPackets = new BlockingCollection<MqttBasePacket>();
|
||||
|
||||
public TestMqttCommunicationAdapter Partner { get; set; }
|
||||
|
||||
@@ -26,8 +26,7 @@ namespace MQTTnet.Tests.Mockups
|
||||
public long BytesSent { get; }
|
||||
public long BytesReceived { get; }
|
||||
|
||||
public Action ReadingPacketStartedCallback { get; set; }
|
||||
public Action ReadingPacketCompletedCallback { get; set; }
|
||||
public bool IsReadingPacket { get; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user