Add support for retained application messages

This commit is contained in:
Christian Kratky
2017-09-30 18:42:41 +02:00
parent 3cce33415d
commit 862f76fea2
24 changed files with 454 additions and 235 deletions
+8 -8
View File
@@ -49,7 +49,7 @@ namespace MQTTnet.Core.Tests
public async Task MqttServer_WillMessage()
{
var s = new MqttServer(new MqttServerOptions(), new List<IMqttServerAdapter> { new TestMqttServerAdapter() });
s.Start();
s.StartAsync();
var willMessage = new MqttApplicationMessage("My/last/will", new byte[0], MqttQualityOfServiceLevel.AtMostOnce, false);
var c1 = ConnectTestClient("c1", null, s);
@@ -63,7 +63,7 @@ namespace MQTTnet.Core.Tests
await Task.Delay(1000);
s.Stop();
s.StopAsync();
Assert.AreEqual(1, receivedMessagesCount);
}
@@ -72,7 +72,7 @@ namespace MQTTnet.Core.Tests
public async Task MqttServer_Unsubscribe()
{
var s = new MqttServer(new MqttServerOptions(), new List<IMqttServerAdapter> { new TestMqttServerAdapter() });
s.Start();
s.StartAsync();
var c1 = ConnectTestClient("c1", null, s);
var c2 = ConnectTestClient("c2", null, s);
@@ -97,7 +97,7 @@ namespace MQTTnet.Core.Tests
await Task.Delay(500);
Assert.AreEqual(1, receivedMessagesCount);
s.Stop();
s.StopAsync();
await Task.Delay(500);
Assert.AreEqual(1, receivedMessagesCount);
@@ -107,7 +107,7 @@ namespace MQTTnet.Core.Tests
public async Task MqttServer_Publish()
{
var s = new MqttServer(new MqttServerOptions(), new List<IMqttServerAdapter> { new TestMqttServerAdapter() });
s.Start();
s.StartAsync();
var c1 = ConnectTestClient("c1", null, s);
@@ -120,7 +120,7 @@ namespace MQTTnet.Core.Tests
s.Publish(message);
await Task.Delay(500);
s.Stop();
s.StopAsync();
Assert.AreEqual(1, receivedMessagesCount);
}
@@ -146,7 +146,7 @@ namespace MQTTnet.Core.Tests
int expectedReceivedMessagesCount)
{
var s = new MqttServer(new MqttServerOptions(), new List<IMqttServerAdapter> { new TestMqttServerAdapter() });
s.Start();
s.StartAsync();
var c1 = ConnectTestClient("c1", null, s);
var c2 = ConnectTestClient("c2", null, s);
@@ -162,7 +162,7 @@ namespace MQTTnet.Core.Tests
await Task.Delay(500);
s.Stop();
s.StopAsync();
Assert.AreEqual(expectedReceivedMessagesCount, receivedMessagesCount);
}
@@ -1,4 +1,5 @@
using System;
using System.Threading.Tasks;
using MQTTnet.Core.Adapter;
using MQTTnet.Core.Server;
@@ -13,12 +14,14 @@ namespace MQTTnet.Core.Tests
ClientConnected?.Invoke(this, eventArgs);
}
public void Start(MqttServerOptions options)
public Task StartAsync(MqttServerOptions options)
{
return Task.FromResult(0);
}
public void Stop()
{
public Task StopAsync()
{
return Task.FromResult(0);
}
}
}