mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-16 01:03:01 +08:00
Add test for simple server and client execution.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MQTTnet.Client;
|
||||
using MQTTnet.Server;
|
||||
|
||||
namespace MQTTnet.TestApp.NetCore
|
||||
{
|
||||
public static class ServerAndClientTest
|
||||
{
|
||||
public static async Task RunAsync()
|
||||
{
|
||||
MqttNetConsoleLogger.ForwardToConsole();
|
||||
|
||||
var factory = new MqttFactory();
|
||||
var server = factory.CreateMqttServer();
|
||||
var client = factory.CreateMqttClient();
|
||||
|
||||
var serverOptions = new MqttServerOptionsBuilder().Build();
|
||||
await server.StartAsync(serverOptions);
|
||||
|
||||
var clientOptions = new MqttClientOptionsBuilder().WithTcpServer("localhost").Build();
|
||||
await client.ConnectAsync(clientOptions);
|
||||
|
||||
await Task.Delay(Timeout.Infinite);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user