End Broker
This commit is contained in:
49
PlantBox.Broker/Broker.cs
Normal file
49
PlantBox.Broker/Broker.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PlantBox.Broker
|
||||
{
|
||||
class Broker
|
||||
{
|
||||
public PlantBoxesManager PlantBoxesManager { get; }
|
||||
public ClientManager ClientManager { get; }
|
||||
public ServerManager ServerManager { get; }
|
||||
|
||||
public bool IsRunning { get; set; }
|
||||
|
||||
public Broker(string[] args)
|
||||
{
|
||||
Console.WriteLine("Initializing Broker...");
|
||||
|
||||
PlantBoxesManager = new PlantBoxesManager();
|
||||
|
||||
PlantBoxesManager.Load();
|
||||
|
||||
ClientManager = new ClientManager(this);
|
||||
ServerManager = new ServerManager(this);
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
Task.Run(() => ClientManager.Start());
|
||||
Task.Run(() => ServerManager.Start());
|
||||
|
||||
string input;
|
||||
do
|
||||
{
|
||||
input = Console.ReadLine().ToLowerInvariant();
|
||||
|
||||
if (input == "save")
|
||||
{
|
||||
PlantBoxesManager.Save();
|
||||
}
|
||||
} while (input != "exit" && input != "stop" && input != "quit");
|
||||
|
||||
Console.WriteLine("Stopping Broker...");
|
||||
|
||||
PlantBoxesManager.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user