Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
MqttModule.cs
1using System;
2using System.Threading.Tasks;
3using Waher.Events;
8
9namespace Waher.Things.Mqtt
10{
14 [Singleton]
15 public class MqttModule : IModule
16 {
20 public async Task Start()
21 {
22 try
23 {
24 await this.CheckNode(MeteringTopology.Root);
25 }
26 catch (Exception ex)
27 {
28 Log.Exception(ex);
29 }
30 }
31
32 private async Task CheckNode(INode Node)
33 {
34 foreach (INode Child in await Node.ChildNodes)
35 {
36 if (Child is MqttBrokerNode BrokerNode)
37 await BrokerNode.GetBroker(); // Makes sure it is initialized.
38 else if (Child is IpHost || Child is NodeCollection)
39 await this.CheckNode(Child);
40 }
41 }
42
46 public Task Stop()
47 {
48 return Task.CompletedTask;
49 }
50 }
51}
Static class managing the application event log. Applications and services log events on this static ...
Definition: Log.cs:14
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
Definition: Log.cs:1657
Node representing an IP Host machine.
Definition: IpHost.cs:25
Defines the Metering Topology data source. This data source contains a tree structure of persistent r...
Node representing a connection to an MQTT broker.
async Task Start()
Starts the module.
Definition: MqttModule.cs:20
Task Stop()
Stops the module.
Definition: MqttModule.cs:46
Interface for late-bound modules loaded at runtime.
Definition: IModule.cs:9
Interface for nodes that are published through the concentrator interface.
Definition: INode.cs:49
Task< IEnumerable< INode > > ChildNodes
Child nodes. If no child nodes are available, null is returned.
Definition: INode.cs:140