Files
MQTTStudy/MQTTSample/MqttBrokerApp/Program.cs
2024-08-09 11:23:16 +09:00

28 lines
728 B
C#

using MQTTnet;
using MQTTnet.Server;
namespace MqttBrokerApp
{
internal class Program
{
private static readonly int PORT = 1883;
static async Task Main(string[] args)
{
var mqttFactory = new MqttFactory();
var mqttServerOption = new MqttServerOptionsBuilder()
.WithDefaultEndpoint()
.WithDefaultEndpointPort(PORT)
.Build();
var mqttServer = mqttFactory.CreateMqttServer(mqttServerOption);
await mqttServer.StartAsync();
Console.WriteLine("MQTT Broker started. Press any key to exit...");
Console.ReadLine();
await mqttServer.StopAsync();
}
}
}