Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Check.cs
1using System;
2using System.Threading.Tasks;
5
7{
12 {
16 public Check()
17 {
18 }
19
23 public override string Name => "Check";
24
32 public override async Task Execute(ChatState State, string[] Arguments, string OrgMessage, ResponseCallbackHandler ResponseCallback)
33 {
34 if (Gateway.SoftwareUpdateClient is null)
35 await XmppServerModule.SendErrorMessage("No software update service available on parent server.", string.Empty, ResponseCallback);
36 else
37 {
38 string MessageId = await ResponseCallback("Subscribing to all software packages.", string.Empty);
39 int NrUpdated = 0;
40
41 await Gateway.SoftwareUpdateClient.SubscribeAsync("*");
42
43 await ResponseCallback("Checking server for new software packages.", MessageId);
44
45 foreach (Networking.XMPP.Software.Package Package in await Gateway.SoftwareUpdateClient.GetPackagesAsync())
46 {
47 if (await XmppServerModule.Instance.CheckSoftwarePackage(Package, ResponseCallback))
48 NrUpdated++;
49 }
50
51 await RuntimeSettings.SetAsync("SW.Update.Last", DateTime.Now);
52
53 switch (NrUpdated)
54 {
55 case 0:
56 await ResponseCallback("No new software packages available.", MessageId);
57 break;
58
59 case 1:
60 await ResponseCallback("1 new software package downloaded.", MessageId);
61 break;
62
63 default:
64 await ResponseCallback(NrUpdated.ToString() + " new software packages downloaded.", MessageId);
65 break;
66 }
67 }
68 }
69
73 public override string[] HelpParagraphs => new string[] { "Checks for new software packages." };
74 }
75}
Static class managing the runtime environment of the IoT Gateway.
Definition: Gateway.cs:126
static SoftwareUpdateClient SoftwareUpdateClient
XMPP Software Updates Client, if such a compoent is available on the XMPP broker.
Definition: Gateway.cs:3283
Static class managing persistent settings.
static async Task< bool > SetAsync(string Key, string Value)
Sets a string-valued setting.
An administrative command with no parameters.
Checks if new software packages are available.
Definition: Check.cs:12
override async Task Execute(ChatState State, string[] Arguments, string OrgMessage, ResponseCallbackHandler ResponseCallback)
Executes the command.
Definition: Check.cs:32
override string Name
Command name
Definition: Check.cs:23
Check()
Checks if new software packages are available.
Definition: Check.cs:16
override string[] HelpParagraphs
Markdown description of syntax.
Definition: Check.cs:73
Service Module hosting the XMPP broker and its components.
delegate Task< string > ResponseCallbackHandler(string Markdown, string MessageId)
Delegate for response callback handler methods.