Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
SensorServerExtension.cs
1using System;
2using System.Collections.Generic;
3using System.Threading.Tasks;
7using Waher.Things;
8
10{
15 {
22 : base(Parent, Model)
23 {
24 }
25
29 public override string LocalName => nameof(SensorServerExtension);
30
38 {
40 }
41
48 public override Task<object> Add(IActor Instance, Waher.Networking.XMPP.XmppClient Client)
49 {
50 SensorServer Extension;
51
52 if (Client.TryGetTag("ProvisioningClient", out object Obj) && Obj is ProvisioningClient ProvisioningClient)
53 Extension = new SensorServer(Client, ProvisioningClient, true);
54 else
55 Extension = new SensorServer(Client, true);
56
57 Client.SetTag("SensorServer", Extension);
58
59 Extension.OnExecuteReadoutRequest += (Sender, e) =>
60 {
61 if (!this.Model.ExternalEvent(Instance, "OnExecuteReadoutRequest",
62 new KeyValuePair<string, object>("e", e),
63 new KeyValuePair<string, object>("Client", Client)))
64 {
65 e.ReportErrors(true, new ThingError(ThingReference.Empty, "No event handler registered on sensor."));
66 }
67
68 return Task.CompletedTask;
69 };
70
71 return Task.FromResult<object>(Extension);
72 }
73
74 }
75}
Root node of a simulation model
Definition: Model.cs:49
bool ExternalEvent(IExternalEventsNode Source, string Name, params KeyValuePair< string, object >[] Arguments)
Method called when an external event has been received.
Definition: Model.cs:889
Abstract base class for IoT XMPP extensions.
override Task< object > Add(IActor Instance, Waher.Networking.XMPP.XmppClient Client)
Adds the extension to the client.
SensorServerExtension(ISimulationNode Parent, Model Model)
Sensor Server XMPP extension
override string LocalName
Local name of XML element defining contents of class.
override ISimulationNode Create(ISimulationNode Parent, Model Model)
Creates a new instance of the node.
Implements an XMPP provisioning client interface.
Implements an XMPP sensor server interface.
Definition: SensorServer.cs:27
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
Definition: XmppClient.cs:59
Contains information about an error on a thing
Definition: ThingError.cs:10
Contains a reference to a thing
static ThingReference Empty
Empty thing reference. Can be used by sensors that are not part of a concentrator during readout.
Basic interface for simulator nodes. Implementing this interface allows classes with default contruct...
ISimulationNode Parent
Parent node in the simulation model.
Basic interface for simulator nodes. Implementing this interface allows classes with default contruct...
Definition: IActor.cs:11
Definition: App.xaml.cs:4