Add server implementation

This commit is contained in:
Christian Kratky
2017-03-26 21:48:50 +02:00
parent 18538ebbb9
commit ee25228c0b
110 changed files with 2164 additions and 496 deletions
+32 -1
View File
@@ -5,6 +5,12 @@
# MQTTnet
MQTTnet is a .NET library for MQTT based communication. It provides a MQTT client and a MQTT server.
## Supported frameworks
* .NET Framework 4.5.2+
* .NET Core 1.0+
* Universal Windows (UWP) 10.0.10240+
# MqttClient
## Example
@@ -81,4 +87,29 @@ while (true)
# MqttServer
## Example
TBD
```c#
var options = new MqttServerOptions
{
ConnectionValidator = p =>
{
if (p.ClientId == "SpecialClient")
{
if (p.Username != "USER" || p.Password != "PASS")
{
return MqttConnectReturnCode.ConnectionRefusedBadUsernameOrPassword;
}
}
return MqttConnectReturnCode.ConnectionAccepted;
}
};
var mqttServer = new MqttServerFactory().CreateMqttServer(options);
mqttServer.Start();
Console.WriteLine("Press any key to exit.");
Console.ReadLine();
mqttServer.Stop();
```