slik-dispenser/backend/Controllers/DispenserController.cs

24 lines
480 B
C#
Raw Normal View History

using Microsoft.AspNetCore.Mvc;
using MQTTnet;
using backend.Application;
namespace backend.Controllers;
[ApiController]
public class DispenserController : ControllerBase
{
[HttpPost("Dispense")]
public void Dispense()
{
Console.WriteLine("Dispensing..");
var message = new MqttApplicationMessageBuilder()
.WithTopic("dispense")
.WithPayload("dispense")
.Build();
ApplicationState.MqttClient!.PublishAsync(message, CancellationToken.None);
}
}