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