Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
SocketEventSinkNode.cs
2using System.Threading.Tasks;
3using System.Xml;
4using Waher.Content;
7using Waher.Things;
10
12{
17 {
22 : base()
23 {
24 }
25
36 string SinkId, string Host, int Port, bool Tls)
37 : base(Source, Parent, SinkId)
38 {
39 this.Host = Host;
40 this.Port = Port;
41 this.Tls = Tls;
42 }
43
47 [Page(7, "Configuration")]
48 [Header(179, "Host:")]
49 [ToolTip(180, "Host name of recipient.")]
50 [Required]
51 public string Host { get; set; }
52
56 [Page(7, "Configuration")]
57 [Header(161, "Port:")]
58 [ToolTip(181, "Port number of the recipient.")]
59 [Required]
60 [Range(1, 65535)]
61 public int Port { get; set; }
62
66 [Page(7, "Configuration")]
67 [Header(163, "Use Encryption (TLS)")]
68 [ToolTip(182, "If TLS is used to connect to the recipient.")]
69 [Required]
70 public bool Tls { get; set; }
71
76 public override Task<string> GetTypeNameAsync(Language Language)
77 {
78 return Language.GetStringAsync(typeof(GatewayConfigSource), 183, "TCP/IP Socket Event Sink");
79 }
80
87 public override async Task<IEnumerable<Parameter>> GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
88 {
89 LinkedList<Parameter> Parameters = (LinkedList<Parameter>)await base.GetDisplayableParametersAsync(Language, Caller);
91
92 Parameters.AddLast(new StringParameter("Host", await Namespace.GetStringAsync(173, "Host"), this.Host));
93 Parameters.AddLast(new Int32Parameter("Port", await Namespace.GetStringAsync(45, "Port Number"), this.Port));
94 Parameters.AddLast(new BooleanParameter("Tls", await Namespace.GetStringAsync(36, "Encrypted"), this.Tls));
95
96 return Parameters;
97 }
98
103 public override void Export(XmlWriter Output)
104 {
105 Output.WriteStartElement("SocketEventSink");
106 Output.WriteAttributeString("id", this.SinkId);
107 Output.WriteAttributeString("host", this.Host);
108 Output.WriteAttributeString("port", this.Port.ToString());
109 Output.WriteAttributeString("tls", CommonTypes.Encode(this.Tls));
110 Output.WriteEndElement();
111 }
112 }
113}
Helps with parsing of commong data types.
Definition: CommonTypes.cs:15
static string Encode(bool x)
Encodes a Boolean for use in XML and other formats.
Definition: CommonTypes.cs:596
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
async Task< Namespace > GetNamespaceAsync(string Name)
Gets the namespace object, given its name, if available.
Definition: Language.cs:99
Contains information about a namespace in a language.
Definition: Namespace.cs:17
Task< LanguageString > GetStringAsync(int Id)
Gets the string object, given its ID, if available.
Definition: Namespace.cs:65
Abstract base class for gateway configuration nodes.
virtual INode Parent
Parent Node, or null if a root node.
GatewayConfigSource Source
Source hosting the node.
Abstract base class for event sink nodes.
override Task< string > GetTypeNameAsync(Language Language)
Gets the type name of the node.
override async Task< IEnumerable< Parameter > > GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
Gets displayable parameters.
SocketEventSinkNode(GatewayConfigSource Source, ConfigurationNode Parent, string SinkId, string Host, int Port, bool Tls)
Representation of a SocketEventSink
override void Export(XmlWriter Output)
Exports the event sink definition to XML.
Tokens available in request.
Definition: RequestOrigin.cs:9