-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathScriptServiceModule.cs
More file actions
54 lines (47 loc) · 1.07 KB
/
ScriptServiceModule.cs
File metadata and controls
54 lines (47 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System.Threading.Tasks;
using Waher.Networking.HTTP;
using Waher.Runtime.Inventory;
namespace Waher.WebService.Script
{
/// <summary>
/// Pluggable module registering the script service to the web server.
/// </summary>
[Singleton]
public class ScriptServiceModule : IModule
{
private HttpServer webServer;
private ScriptService instance;
/// <summary>
/// Pluggable module registering the script service to the web server.
/// </summary>
public ScriptServiceModule()
{
}
/// <summary>
/// Starts the module.
/// </summary>
public Task Start()
{
if (Types.TryGetModuleParameter("HTTP", out HttpServer WebServer))
{
this.webServer = WebServer;
this.instance = new ScriptService("/Evaluate");
this.webServer.Register(this.instance);
}
return Task.CompletedTask;
}
/// <summary>
/// Stops the module.
/// </summary>
public Task Stop()
{
if (!(this.webServer is null))
{
this.webServer.Unregister(this.instance);
this.webServer = null;
this.instance = null;
}
return Task.CompletedTask;
}
}
}