End Broker
This commit is contained in:
@@ -8,30 +8,14 @@ namespace PlantBox.Broker
|
||||
{
|
||||
class Program
|
||||
{
|
||||
public static Broker Broker { get; private set; }
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello World!");
|
||||
var listener = new TcpListener(IPAddress.Any, Connection.TCP_PORT);
|
||||
listener.Start();
|
||||
Broker = new Broker(args);
|
||||
Broker.Start();
|
||||
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
var client = listener.AcceptTcpClient();
|
||||
var stream = new CommandStream(client.GetStream());
|
||||
|
||||
(var command, var ping) = stream.Receive<PingCommand>();
|
||||
Console.WriteLine(command);
|
||||
Console.WriteLine($"Ping: {ping.Message}");
|
||||
|
||||
stream.Send(new PingCommand(ping.Message).ToCommandPacket(command.ID));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Console.WriteLine("Broker stopped");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user