mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-16 17:23:04 +08:00
Refactoring
This commit is contained in:
+2
-17
@@ -2,7 +2,7 @@
|
||||
<package >
|
||||
<metadata>
|
||||
<id>MQTTnet</id>
|
||||
<version>2.5.0</version>
|
||||
<version>2.5.1</version>
|
||||
<authors>Christian Kratky</authors>
|
||||
<owners>Christian Kratky</owners>
|
||||
<licenseUrl>https://github.com/chkr1011/MQTTnet/blob/master/LICENSE</licenseUrl>
|
||||
@@ -10,22 +10,7 @@
|
||||
<iconUrl>https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png</iconUrl>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<description>MQTTnet is a high performance .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker).</description>
|
||||
<releaseNotes>* [Core] Merged the platform specific projects (Thanks to @JanEggers)
|
||||
* [Core] Migrated the trace to a non-static approach (Breaking Change!)
|
||||
* [Core] Added a builder for application messages using a fluent API
|
||||
* [Core] Introduced CI and DI (Thanks to @JanEggers)
|
||||
* [Core] Added interfaces for publishing and receiving which applies to every client and server (Thanks to @ChristianRiedl)
|
||||
* [Core] Fixed an issue when reading from closed streams
|
||||
* [Client] Added a first version of a managed client which will manage the connection, subscription etc. automatically (Thanks to @JTrotta)
|
||||
* [Client] The session state response from the server is now returned in the _ConnectAsync_ method and also part of the _Connected_ event args
|
||||
* [Client] Added a _TopicFilterBuilder_ using a fluent API (Namespace Changes!)
|
||||
* [Client] Added several new options for the WebSocket channel (Thanks to @ChristianRiedl)
|
||||
* [Client] Refactored the options and added a builder using a fluent API (Breaking Change!)
|
||||
* [Client] Added more options for WebSocket connections like RequestHeaders, SubProtocol etc.
|
||||
* [Server] Added support for WebSockets via ASP.NET Core 2.0 (additional nuget) (Thanks to @ChristianRiedl, @JanEggers)
|
||||
* [Server] Added support for a custom application message interceptor
|
||||
* [Server] Fixed an issue with dropped connections on UWP (Thanks to @haeberle)
|
||||
* [Server] Added support for a custom subscription interceptor which allows denying of subscriptions and closing the connection
|
||||
<releaseNotes>*
|
||||
</releaseNotes>
|
||||
<copyright>Copyright Christian Kratky 2016-2017</copyright>
|
||||
<tags>MQTT Message Queue Telemetry Transport MQTTClient MQTTServer Server MQTTBroker Broker NETStandard IoT InternetOfThings Messaging Hardware Arduino Sensor Actuator M2M ESP Smart Home Cities Automation Xamarin</tags>
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace MQTTnet.Core.Tests
|
||||
public async Task MqttServer_WillMessage()
|
||||
{
|
||||
var serverAdapter = new TestMqttServerAdapter();
|
||||
|
||||
var services = new ServiceCollection()
|
||||
.AddLogging()
|
||||
.AddMqttServer()
|
||||
@@ -70,7 +71,7 @@ namespace MQTTnet.Core.Tests
|
||||
var c2 = await serverAdapter.ConnectTestClient(s, "c2", willMessage);
|
||||
|
||||
c1.ApplicationMessageReceived += (_, __) => receivedMessagesCount++;
|
||||
await c1.SubscribeAsync(new TopicFilter("#", MqttQualityOfServiceLevel.AtMostOnce));
|
||||
await c1.SubscribeAsync(new TopicFilter("#"));
|
||||
|
||||
await c2.DisconnectAsync();
|
||||
|
||||
@@ -80,6 +81,7 @@ namespace MQTTnet.Core.Tests
|
||||
{
|
||||
await s.StopAsync();
|
||||
}
|
||||
|
||||
Assert.AreEqual(1, receivedMessagesCount);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace MQTTnet.Core.Tests
|
||||
|
||||
foreach (var packet in packets)
|
||||
{
|
||||
Partner.SendPacketInternal(packet);
|
||||
Partner.EnqueuePacketInternal(packet);
|
||||
}
|
||||
|
||||
return Task.FromResult(0);
|
||||
@@ -46,7 +46,7 @@ namespace MQTTnet.Core.Tests
|
||||
return Task.Run(() => _incomingPackets.Take(), cancellationToken);
|
||||
}
|
||||
|
||||
private void SendPacketInternal(MqttBasePacket packet)
|
||||
private void EnqueuePacketInternal(MqttBasePacket packet)
|
||||
{
|
||||
if (packet == null) throw new ArgumentNullException(nameof(packet));
|
||||
|
||||
|
||||
+2
-2
@@ -4,11 +4,11 @@ using MQTTnet.Core.Client;
|
||||
|
||||
namespace MQTTnet.Core.Tests
|
||||
{
|
||||
public class MqttCommunicationAdapterFactory : IMqttCommunicationAdapterFactory
|
||||
public class TestMqttCommunicationAdapterFactory : IMqttCommunicationAdapterFactory
|
||||
{
|
||||
private readonly IMqttCommunicationAdapter _adapter;
|
||||
|
||||
public MqttCommunicationAdapterFactory(IMqttCommunicationAdapter adapter)
|
||||
public TestMqttCommunicationAdapterFactory(IMqttCommunicationAdapter adapter)
|
||||
{
|
||||
_adapter = adapter;
|
||||
}
|
||||
@@ -17,7 +17,11 @@ namespace MQTTnet.Core.Tests
|
||||
adapterA.Partner = adapterB;
|
||||
adapterB.Partner = adapterA;
|
||||
|
||||
var client = new MqttClient(new MqttCommunicationAdapterFactory(adapterA), new TestLogger<MqttClient>(), new MqttPacketDispatcher(new TestLogger<MqttPacketDispatcher>()));
|
||||
var client = new MqttClient(
|
||||
new TestMqttCommunicationAdapterFactory(adapterA),
|
||||
new TestLogger<MqttClient>(),
|
||||
new MqttPacketDispatcher(new TestLogger<MqttPacketDispatcher>()));
|
||||
|
||||
var connected = WaitForClientToConnect(server, clientId);
|
||||
|
||||
FireClientAcceptedEvent(adapterB);
|
||||
@@ -29,8 +33,6 @@ namespace MQTTnet.Core.Tests
|
||||
ChannelOptions = new MqttClientTcpOptions()
|
||||
};
|
||||
|
||||
options.ChannelOptions = new MqttClientTcpOptions();
|
||||
|
||||
await client.ConnectAsync(options);
|
||||
await connected;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user