Files
PlantBox/PlantBox.Broker/Program.cs
2019-03-23 22:41:13 +01:00

38 lines
1019 B
C#

using PlantBox.Shared.Communication;
using PlantBox.Shared.Communication.Commands;
using System;
using System.Net;
using System.Net.Sockets;
namespace PlantBox.Broker
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
var listener = new TcpListener(IPAddress.Any, Connection.TCP_PORT);
listener.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)
{
}
}
}
}
}