1using System.Collections.Generic;
3using System.Threading.Tasks;
14 private static readonly Dictionary<string, MqttBroker> brokers =
new Dictionary<string, MqttBroker>();
27 public static string GetKey(
string Host,
int Port,
bool Tls,
bool TrustServer,
string UserName,
string Password,
string ConnectionSubscription)
29 StringBuilder sb =
new StringBuilder();
32 sb.AppendLine(Port.ToString());
33 sb.AppendLine(Tls.ToString());
34 sb.AppendLine(TrustServer.ToString());
35 sb.AppendLine(UserName);
36 sb.AppendLine(Password);
37 sb.AppendLine(ConnectionSubscription);
45 public static async Task<MqttBroker>
GetBroker(
MqttBrokerNode Node,
string Key,
string Host,
int Port,
bool Tls,
bool TrustServer,
46 string UserName,
string Password,
string ConnectionSubscription,
string WillTopic,
string WillData,
bool WillRetain,
53 if (!brokers.TryGetValue(Key, out Broker))
57 if (!(Broker is
null))
59 await Broker.
SetWill(WillTopic, WillData, WillRetain, WillQoS);
64 Broker =
new MqttBroker(Node, Host, Port, Tls, TrustServer, UserName, Password, ConnectionSubscription,
65 WillTopic, WillData, WillRetain, WillQoS);
72 if (brokers.TryGetValue(Key, out Result))
76 brokers[Key] = Result = Broker;
81 if (!(Obsolete is
null))
97 if (!brokers.TryGetValue(Key, out Broker))
98 return Task.CompletedTask;
Contains methods for simple hash calculations.
static string ComputeSHA1HashString(byte[] Data)
Computes the SHA-1 hash of a block of binary data.
MQTT Broker connection object.
bool Remove(string LocalTopic)
Removes a child topic
Task DisposeAsync()
Closes the connection and disposes of all resources.
async Task SetWill(string WillTopic, string WillData, bool WillRetain, MqttQualityOfService WillQoS)
TODO
Static class managing connections to MQTT brokers.
static async Task< MqttBroker > GetBroker(MqttBrokerNode Node, string Key, string Host, int Port, bool Tls, bool TrustServer, string UserName, string Password, string ConnectionSubscription, string WillTopic, string WillData, bool WillRetain, MqttQualityOfService WillQoS)
TODO
static string GetKey(string Host, int Port, bool Tls, bool TrustServer, string UserName, string Password, string ConnectionSubscription)
Gets sort key for MQTT broker
static Task DestroyBroker(string Key)
TODO
Node representing a connection to an MQTT broker.
MqttQualityOfService
MQTT Quality of Service level.