End Broker

This commit is contained in:
2019-04-24 19:27:40 +02:00
parent a1e1d43a6f
commit e3cc6392a7
12 changed files with 518 additions and 23 deletions

49
PlantBox.Broker/Broker.cs Normal file
View 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();
}
}
}