Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
LocalWebServerNode.cs
1using System;
3using System.Threading.Tasks;
9
10namespace Waher.Things.Http
11{
16 {
21 : base()
22 {
23 }
24
28 public override Task<string> GetTypeNameAsync(Language Language)
29 {
30 return Language.GetStringAsync(typeof(LocalWebServerNode), 1, "Local Web Server");
31 }
32
36 public override Task<bool> AcceptsChildAsync(INode Child)
37 {
38 return Task.FromResult(Child is ExternalWebNode);
39 }
40
46 public override Task<bool> AcceptsParentAsync(INode Parent)
47 {
48 return Task.FromResult(Parent is Root);
49 }
50
51 #region ICommunicationLayer
52
57 public bool DecoupledEvents => HttpModule.WebServer?.DecoupledEvents ?? false;
58
63 public void Add(ISniffer Sniffer)
64 {
65 HttpModule.WebServer?.Add(Sniffer);
66 HttpModule.Scheduler.Add(
67 DateTime.Now.AddHours(1),
68 (_) => this.Remove(Sniffer),
69 null);
70 }
71
76 public void AddRange(IEnumerable<ISniffer> Sniffers)
77 {
78 HttpModule.WebServer?.AddRange(Sniffers);
79 HttpModule.Scheduler.Add(
80 DateTime.Now.AddHours(1),
81 (_) =>
82 {
83 foreach (ISniffer Sniffer in Sniffers)
84 this.Remove(Sniffer);
85 },
86 null);
87 }
88
94 public bool Remove(ISniffer Sniffer) => HttpModule.WebServer?.Remove(Sniffer) ?? false;
95
99 public ISniffer[] Sniffers => HttpModule.WebServer?.Sniffers ?? Array.Empty<ISniffer>();
100
104 public bool HasSniffers => HttpModule.WebServer?.HasSniffers ?? false;
105
110 public IEnumerator<ISniffer> GetEnumerator() => HttpModule.WebServer?.GetEnumerator() ?? ((IEnumerable<ISniffer>)(Array.Empty<ISniffer>())).GetEnumerator();
111
116 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => HttpModule.WebServer?.GetEnumerator() ?? (Array.Empty<ISniffer>()).GetEnumerator();
117
122 public void ReceiveBinary(int Count) => HttpModule.WebServer?.ReceiveBinary(Count);
123
130 public void ReceiveBinary(bool ConstantBuffer, byte[] Data) => HttpModule.WebServer?.ReceiveBinary(ConstantBuffer, Data);
131
140 public void ReceiveBinary(bool ConstantBuffer, byte[] Data, int Offset, int Count) => HttpModule.WebServer?.ReceiveBinary(ConstantBuffer, Data, Offset, Count);
141
146 public void TransmitBinary(int Count) => HttpModule.WebServer?.TransmitBinary(Count);
147
154 public void TransmitBinary(bool ConstantBuffer, byte[] Data) => HttpModule.WebServer?.TransmitBinary(ConstantBuffer, Data);
155
164 public void TransmitBinary(bool ConstantBuffer, byte[] Data, int Offset, int Count) => HttpModule.WebServer?.TransmitBinary(ConstantBuffer, Data, Offset, Count);
165
170 public void ReceiveText(string Text) => HttpModule.WebServer?.ReceiveText(Text);
171
176 public void TransmitText(string Text) => HttpModule.WebServer?.TransmitText(Text);
177
182 public void Information(string Comment) => HttpModule.WebServer?.Information(Comment);
183
188 public void Warning(string Warning) => HttpModule.WebServer?.Warning(Warning);
189
194 public void Error(string Error) => HttpModule.WebServer?.Error(Error);
195
200 public void Exception(Exception Exception) => HttpModule.WebServer?.Exception(Exception);
201
206 public void Exception(string Exception) => HttpModule.WebServer?.Exception(Exception);
207
213 public void ReceiveBinary(DateTime Timestamp, int Count) => HttpModule.WebServer?.ReceiveBinary(Timestamp, Count);
214
222 public void ReceiveBinary(DateTime Timestamp, bool ConstantBuffer, byte[] Data) => HttpModule.WebServer?.ReceiveBinary(Timestamp, ConstantBuffer, Data);
223
233 public void ReceiveBinary(DateTime Timestamp, bool ConstantBuffer, byte[] Data, int Offset, int Count) => HttpModule.WebServer?.ReceiveBinary(Timestamp, ConstantBuffer, Data, Offset, Count);
234
240 public void TransmitBinary(DateTime Timestamp, int Count) => HttpModule.WebServer?.TransmitBinary(Timestamp, Count);
241
249 public void TransmitBinary(DateTime Timestamp, bool ConstantBuffer, byte[] Data) => HttpModule.WebServer?.TransmitBinary(Timestamp, ConstantBuffer, Data);
250
260 public void TransmitBinary(DateTime Timestamp, bool ConstantBuffer, byte[] Data, int Offset, int Count) => HttpModule.WebServer?.TransmitBinary(Timestamp, ConstantBuffer, Data, Offset, Count);
261
267 public void ReceiveText(DateTime Timestamp, string Text) => HttpModule.WebServer?.ReceiveText(Timestamp, Text);
268
274 public void TransmitText(DateTime Timestamp, string Text) => HttpModule.WebServer?.TransmitText(Timestamp, Text);
275
281 public void Information(DateTime Timestamp, string Comment) => HttpModule.WebServer?.Information(Timestamp, Comment);
282
288 public void Warning(DateTime Timestamp, string Warning) => HttpModule.WebServer?.Warning(Timestamp, Warning);
289
295 public void Error(DateTime Timestamp, string Error) => HttpModule.WebServer?.Error(Timestamp, Error);
296
302 public void Exception(DateTime Timestamp, string Exception) => HttpModule.WebServer?.Exception(Timestamp, Exception);
303
309 public void Exception(DateTime Timestamp, Exception Exception) => HttpModule.WebServer?.Exception(Timestamp, Exception);
310
311 #endregion
312 }
313}
Contains information about a language.
Definition: Language.cs:17
Task< string > GetStringAsync(Type Type, int Id, string Default)
Gets the string value of a string ID. If no such string exists, a string is created with the default ...
Definition: Language.cs:209
Node representing an external web node.
Node representing the local web server.
void TransmitBinary(bool ConstantBuffer, byte[] Data, int Offset, int Count)
Called when binary data has been transmitted.
ISniffer[] Sniffers
Registered sniffers.
override Task< bool > AcceptsChildAsync(INode Child)
TODO
bool HasSniffers
If there are sniffers registered on the object.
bool Remove(ISniffer Sniffer)
Removes a sniffer, if registered.
void Information(DateTime Timestamp, string Comment)
Called to inform the viewer of something.
void Add(ISniffer Sniffer)
Adds a sniffer to the node.
void Error(string Error)
Called to inform the viewer of an error state.
void Exception(string Exception)
Called to inform the viewer of an exception state.
void ReceiveText(DateTime Timestamp, string Text)
Called when text has been received.
void Error(DateTime Timestamp, string Error)
Called to inform the viewer of an error state.
LocalWebServerNode()
Node representing a connection to an MQTT broker.
void ReceiveBinary(DateTime Timestamp, bool ConstantBuffer, byte[] Data, int Offset, int Count)
Called when binary data has been received.
void TransmitBinary(int Count)
Called when binary data has been transmitted.
void Exception(DateTime Timestamp, Exception Exception)
Called to inform the viewer of an exception state.
void AddRange(IEnumerable< ISniffer > Sniffers)
Adds a range of sniffers to the node.
void Warning(string Warning)
Called to inform the viewer of a warning state.
override Task< string > GetTypeNameAsync(Language Language)
Type name representing data.
void Exception(Exception Exception)
Called to inform the viewer of an exception state.
void ReceiveBinary(bool ConstantBuffer, byte[] Data, int Offset, int Count)
Called when binary data has been received.
void TransmitBinary(DateTime Timestamp, bool ConstantBuffer, byte[] Data, int Offset, int Count)
Called when binary data has been transmitted.
void ReceiveBinary(bool ConstantBuffer, byte[] Data)
Called when binary data has been received.
void Information(string Comment)
Called to inform the viewer of something.
override Task< bool > AcceptsParentAsync(INode Parent)
If the node accepts a presumptive parent, i.e. can be added to that parent (if that parent accepts th...
void TransmitBinary(bool ConstantBuffer, byte[] Data)
Called when binary data has been transmitted.
void ReceiveText(string Text)
Called when text has been received.
void ReceiveBinary(DateTime Timestamp, bool ConstantBuffer, byte[] Data)
Called when binary data has been received.
void TransmitText(DateTime Timestamp, string Text)
Called when text has been transmitted.
void ReceiveBinary(DateTime Timestamp, int Count)
Called when binary data has been received.
void ReceiveBinary(int Count)
Called when binary data has been received.
void TransmitBinary(DateTime Timestamp, bool ConstantBuffer, byte[] Data)
Called when binary data has been transmitted.
void TransmitText(string Text)
Called when text has been transmitted.
bool DecoupledEvents
If events raised from the communication layer are decoupled, i.e. executed in parallel with the sourc...
IEnumerator< ISniffer > GetEnumerator()
Returns an enumerator that iterates through the collection.
void TransmitBinary(DateTime Timestamp, int Count)
Called when binary data has been transmitted.
void Exception(DateTime Timestamp, string Exception)
Called to inform the viewer of an exception state.
void Warning(DateTime Timestamp, string Warning)
Called to inform the viewer of a warning state.
Base class for all metering nodes.
Definition: MeteringNode.cs:30
INode Parent
Parent Node, or null if a root node.
Class for the root node of the Metering topology.
Definition: Root.cs:10
Interface for observable classes implementing communication protocols.
Interface for sniffers. Sniffers can be added to ICommunicationLayer classes to eavesdrop on communic...
Definition: ISniffer.cs:10
Interface for nodes that are published through the concentrator interface.
Definition: INode.cs:49
Definition: ImplTypes.g.cs:58