You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ServerAndClientTest.cs 823 B

6 vuotta sitten
12345678910111213141516171819202122232425262728
  1. using System.Threading;
  2. using System.Threading.Tasks;
  3. using MQTTnet.Client;
  4. using MQTTnet.Client.Options;
  5. using MQTTnet.Server;
  6. namespace MQTTnet.TestApp.NetCore
  7. {
  8. public static class ServerAndClientTest
  9. {
  10. public static async Task RunAsync()
  11. {
  12. MqttNetConsoleLogger.ForwardToConsole();
  13. var factory = new MqttFactory();
  14. var server = factory.CreateMqttServer();
  15. var client = factory.CreateMqttClient();
  16. var serverOptions = new MqttServerOptionsBuilder().Build();
  17. await server.StartAsync(serverOptions);
  18. var clientOptions = new MqttClientOptionsBuilder().WithTcpServer("localhost").Build();
  19. await client.ConnectAsync(clientOptions);
  20. await Task.Delay(Timeout.Infinite);
  21. }
  22. }
  23. }