Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ClientConnections.cs
1using System;
2using System.Collections.Generic;
3using System.Threading.Tasks;
5using Waher.Things;
7
9{
10 public class ClientConnections : INode
11 {
12 public ClientConnections()
13 {
14 }
15
16 public string LocalId => "C2S";
17 public string LogId => "C2S";
18 public string NodeId => "C2S";
19 public string SourceId => "Connections";
20 public string Partition => string.Empty;
21 public bool ChildrenOrdered => false;
22 public bool IsReadable => false;
23 public bool IsControllable => false;
24 public bool HasCommands => false;
25 public INode Parent => null;
26 public DateTime LastChanged => DateTime.MinValue;
27 public Task<IEnumerable<ICommand>> Commands => null;
28
30 {
31 get
32 {
33 return NodeState.None;
34 }
35 }
36
37 public Task<bool> AcceptsChildAsync(INode Child)
38 {
39 return Task.FromResult(Child is ClientConnection);
40 }
41
42 public Task<bool> AcceptsParentAsync(INode Parent)
43 {
44 return Task.FromResult(false);
45 }
46
47 public Task AddAsync(INode Child)
48 {
49 throw new NotSupportedException();
50 }
51
52 public Task<bool> CanAddAsync(RequestOrigin Caller)
53 {
54 return Task.FromResult(false);
55 }
56
57 public Task<bool> CanDestroyAsync(RequestOrigin Caller)
58 {
59 return Task.FromResult(false);
60 }
61
62 public Task<bool> CanEditAsync(RequestOrigin Caller)
63 {
64 return Task.FromResult(false);
65 }
66
67 public Task<bool> CanViewAsync(RequestOrigin Caller)
68 {
69 return XmppServerModule.IsAdmin(Caller.From);
70 }
71
72 public Task DestroyAsync()
73 {
74 throw new NotSupportedException();
75 }
76
77 public async Task<IEnumerable<Parameter>> GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
78 {
79 LinkedList<Parameter> Parameters = new LinkedList<Parameter>();
80
81 Parameters.AddLast(new Int32Parameter("NrConnections", await Language.GetStringAsync(typeof(XmppServerModule), 10, "#Connections"), XmppServerModule.Server.NrClientConnections));
82
83 return Parameters;
84 }
85
86 public bool HasChildren => XmppServerModule.Server.NrClientConnections > 0;
87
88 public Task<IEnumerable<INode>> ChildNodes
89 {
90 get
91 {
92 Networking.XMPP.Server.IClientConnection[] Connections = XmppServerModule.Server.GetClientConnections();
93 int i, c = Connections.Length;
94 ClientConnection[] Result = new ClientConnection[c];
95
96 for (i = 0; i < c; i++)
97 Result[i] = new ClientConnection(this, Connections[i]);
98
99 return Task.FromResult<IEnumerable<INode>>(Result);
100 }
101 }
102
103 public Task<IEnumerable<Message>> GetMessagesAsync(RequestOrigin Caller)
104 {
105 return Task.FromResult<IEnumerable<Message>>(null);
106 }
107
108 public Task<string> GetTypeNameAsync(Language Language)
109 {
110 return Language.GetStringAsync(typeof(XmppServerModule), 11, "C2S Connections");
111 }
112
113 public Task<bool> MoveDownAsync(RequestOrigin Caller)
114 {
115 return Task.FromResult(false);
116 }
117
118 public Task<bool> MoveUpAsync(RequestOrigin Caller)
119 {
120 return Task.FromResult(false);
121 }
122
123 public Task UpdateAsync()
124 {
125 return Task.CompletedTask;
126 }
127
128 public Task<bool> RemoveAsync(INode Child)
129 {
130 return Task.FromResult(false);
131 }
132
133 }
134}
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
Task< bool > CanAddAsync(RequestOrigin Caller)
If the node can be added to by the caller.
Task< bool > MoveDownAsync(RequestOrigin Caller)
Tries to move the node down.
Task< bool > CanViewAsync(RequestOrigin Caller)
If the node is visible to the caller.
string Partition
Optional partition in which the Node ID is unique.
bool HasCommands
If the node has registered commands or not.
string LocalId
If provided, an ID for the node, but unique locally between siblings. Can be null,...
Task< string > GetTypeNameAsync(Language Language)
Gets the type name of the node.
NodeState State
Current overall state of the node.
Task< IEnumerable< ICommand > > Commands
Available command objects. If no commands are available, null is returned.
Task DestroyAsync()
Destroys the node. If it is a child to a parent node, it is removed from the parent first.
bool ChildrenOrdered
If the children of the node have an intrinsic order (true), or if the order is not important (false).
Task< bool > MoveUpAsync(RequestOrigin Caller)
Tries to move the node up.
Task< IEnumerable< INode > > ChildNodes
Child nodes. If no child nodes are available, null is returned.
Task< bool > CanEditAsync(RequestOrigin Caller)
If the node can be edited by the caller.
bool HasChildren
If the source has any child sources.
Task< bool > CanDestroyAsync(RequestOrigin Caller)
If the node can be destroyed to by the caller.
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 ...
Task< bool > RemoveAsync(INode Child)
Removes a child from the node.
Task< IEnumerable< Message > > GetMessagesAsync(RequestOrigin Caller)
Gets messages logged on the node.
Task UpdateAsync()
Updates the node (in persisted storage).
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...
string SourceId
Optional ID of source containing node.
async Task< IEnumerable< Parameter > > GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
Gets displayable parameters.
string LogId
If provided, an ID for the node, as it would appear or be used in system logs. Can be null,...
Task AddAsync(INode Child)
Adds a new child to the node.
Service Module hosting the XMPP broker and its components.
Tokens available in request.
Definition: RequestOrigin.cs:9
string From
Address of caller.
Interface for nodes that are published through the concentrator interface.
Definition: INode.cs:49
NodeState
State of a node.
Definition: INode.cs:13