-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnvironment.cs
More file actions
65 lines (55 loc) · 1.77 KB
/
Copy pathEnvironment.cs
File metadata and controls
65 lines (55 loc) · 1.77 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
55
56
57
58
59
60
61
62
63
64
65
using Akka.Actor;
using Akka.Configuration;
using DroneSystemAPI;
using DroneSystemAPI.APIClasses;
namespace TerminalUI
{
internal class Environment
{
public IDictionary<int, ActorSystem> ActorSystems { get; }
public ActorSystem InterfaceActorSystem { get; }
public IDictionary<string, MissionInfo> Missions { get; }
/// <summary>
/// API principale per coordinare il sistema (da "client")
/// </summary>
public DroneDeliverySystemAPI DroneDeliverySystemAPI { get; }
public Environment()
{
// inizializzo actor system locale usato a scopo di interfaccia
InterfaceActorSystem = ActorSystem.Create(
"InterfaceActorSystem",
ConfigurationFactory.ParseString(InterfaceActorSystemHocon));
// inizializzo le liste degli actor system gestiti localmente
ActorSystems = new Dictionary<int, ActorSystem>();
Missions = new Dictionary<string, MissionInfo>();
// inizializzo API
DroneDeliverySystemAPI = new DroneDeliverySystemAPI(
InterfaceActorSystem,
Config2.Default().SystemName,
Config2.Default().RepositoryActorName
);
}
public void Terminate()
{
InterfaceActorSystem?.Terminate();
foreach (var system in ActorSystems)
{
ActorSystems.Remove(system);
system.Value.Terminate();
}
}
private static string InterfaceActorSystemHocon => @"
akka {
loglevel = WARNING
actor {
provider = remote
}
remote {
dot-netty.tcp {
port = 0
hostname = localhost
}
}
}";
}
}