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.
 
 
 
 

28 lines
637 B

  1. @page "/counter"
  2. @using MQTTnet.Client.Options
  3. @using System.Threading
  4. <h1>Counter</h1>
  5. <p>Current count: @currentCount</p>
  6. <button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
  7. @code {
  8. private int currentCount = 0;
  9. private async Task IncrementCount()
  10. {
  11. var mqttFactory = new MqttFactory();
  12. var client = mqttFactory.CreateMqttClient();
  13. var options = new MqttClientOptionsBuilder()
  14. .WithWebSocketServer("192.168.1.15:80/mqtt")
  15. .Build();
  16. await client.ConnectAsync(options, CancellationToken.None);
  17. currentCount++;
  18. }
  19. }