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.
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|