Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
MyIp.cs
1using System.Threading.Tasks;
3using Waher.Script;
5
7{
12 {
16 public MyIp()
17 {
18 }
19
23 public override string Name => "MyIp";
24
32 public override async Task Execute(ChatState State, string[] Arguments, string OrgMessage, ResponseCallbackHandler ResponseCallback)
33 {
34 string DomainName = await LegalComponent.GetOnboardingNeuronDomainName();
35 string s;
36
37 if (!IoTGateway.Setup.DomainConfiguration.Instance.DynamicDns ||
38 string.IsNullOrEmpty(s = IoTGateway.Setup.DomainConfiguration.Instance.CheckIpScript))
39 {
40 s = "Before(Post(\"https://" + DomainName + "/ID/CountryCode.ws\",\"\",{\"Accept\":\"application/json\"}).RemoteEndPoint,\":\")";
41 }
42
43 Expression Exp = new Expression(s);
44 object Result = await Exp.EvaluateAsync(HttpServer.CreateVariables());
45
46 await ResponseCallback(Result?.ToString() ?? "null", string.Empty);
47 }
48
52 public override string[] HelpParagraphs => new string[] { "Returns the current public IP, as seen by external parties." };
53 }
54}
Implements an HTTP server.
Definition: HttpServer.cs:36
static Variables CreateVariables()
Creates a new collection of variables, that contains access to the global set of variables.
Definition: HttpServer.cs:1604
Class managing a script expression.
Definition: Expression.cs:39
async Task< object > EvaluateAsync(Variables Variables)
Evaluates the expression, using the variables provided in the Variables collection....
Definition: Expression.cs:4275
An administrative command with no parameters.
Returns the current public IP, as seen by external parties.
Definition: MyIp.cs:12
override string Name
Command name
Definition: MyIp.cs:23
MyIp()
Returns the current public IP, as seen by external parties.
Definition: MyIp.cs:16
override async Task Execute(ChatState State, string[] Arguments, string OrgMessage, ResponseCallbackHandler ResponseCallback)
Executes the command.
Definition: MyIp.cs:32
override string[] HelpParagraphs
Markdown description of syntax.
Definition: MyIp.cs:52
delegate Task< string > ResponseCallbackHandler(string Markdown, string MessageId)
Delegate for response callback handler methods.