Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ConcentratorDevice.cs
1using System.Collections.Generic;
2using System.Threading.Tasks;
7
8namespace Waher.Things.Xmpp
9{
14 {
19 : base()
20 {
21 }
22
28 public override Task<string> GetTypeNameAsync(Language Language)
29 {
30 return Language.GetStringAsync(typeof(ConcentratorDevice), 1, "XMPP Concentrator");
31 }
32
38 public override Task<bool> AcceptsChildAsync(INode Child)
39 {
40 return Task.FromResult(Child is ConcentratorSourceNode || Child is ConcentratorNode);
41 }
42
46 public override Task<IEnumerable<ICommand>> Commands => this.GetCommands();
47
48 private async Task<IEnumerable<ICommand>> GetCommands()
49 {
50 List<ICommand> Result = new List<ICommand>();
51 Result.AddRange(await base.Commands);
52
53 XmppClient Client = await this.GetClient();
54 if (!(Client is null))
55 {
56 this.GetRemoteFullJid(Client, out bool HasContact, out bool HasSubscription);
57
58 if (HasContact && HasSubscription)
59 Result.Add(new ScanRootSources(this));
60 }
61
62 return Result.ToArray();
63 }
64
70 public async Task<ConcentratorClient> GetConcentratorClient()
71 {
72 XmppClient Client = await this.GetClient();
73 if (Client is null)
74 return null;
75
77 return null;
78
79 return ConcentratorClient;
80 }
81 }
82}
Implements an XMPP concentrator client interface.
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
Definition: XmppClient.cs:59
bool TryGetExtension(Type Type, out IXmppExtension Extension)
Tries to get a registered extension of a specific type from the client.
Definition: XmppClient.cs:7318
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
Scans a concentrator node for its root sources.
Node representing an XMPP concentrator.
override Task< bool > AcceptsChildAsync(INode Child)
If the node accepts a presumptive child, i.e. can receive as a child (if that child accepts the node ...
async Task< ConcentratorClient > GetConcentratorClient()
Gets the concentrator client associated with the XMPP client associated with the node.
override Task< IEnumerable< ICommand > > Commands
Available command objects. If no commands are available, null is returned.
ConcentratorDevice()
Node representing an XMPP concentrator.
override Task< string > GetTypeNameAsync(Language Language)
Gets the type name of the node.
Base class for nodes in a remote concentrator.
Node representing a data source in an XMPP concentrator.
Node representing a device that is connected to XMPP.
string GetRemoteFullJid(XmppClient Client, out bool HasContact, out bool HasSubscription)
Gets the Full JID of the connected device.
async Task< XmppClient > GetClient()
Gets the XMPP Client associated with node.
Definition: XmppDevice.cs:36
Interface for nodes that are published through the concentrator interface.
Definition: INode.cs:49