46 lines
1.3 KiB
C#
46 lines
1.3 KiB
C#
using System;
|
|
|
|
using System.Net;
|
|
using System.Threading.Tasks;
|
|
|
|
using SBRL.Utilities;
|
|
using PixelHub.Net;
|
|
using System.Net.NetworkInformation;
|
|
|
|
namespace PixelHub.Server
|
|
{
|
|
static class ServerProgram
|
|
{
|
|
private static int port = 5050;
|
|
private static PrefixedWriter systemWriter = new PrefixedWriter(Console.Out) { Prefix = "[System] " };
|
|
private static PrefixedWriter beaconWriter = new PrefixedWriter(Console.Out) { Prefix = "[Beacon] " };
|
|
private static PrefixedWriter serverWriter = new PrefixedWriter(Console.Out) { Prefix = "[Server] " };
|
|
|
|
public static void Main(string[] args)
|
|
{
|
|
systemWriter.WriteLine("Booting server.");
|
|
DiscoveryBeacon beacon = new DiscoveryBeacon(
|
|
IPAddress.Parse("239.62.148.30"), port,
|
|
beaconWriter
|
|
);
|
|
beacon.LocalIP = IPAddress.Parse("10.42.0.1");
|
|
beacon.NetworkInterfaceName = "wlp2s0";
|
|
|
|
PixelHub server = new PixelHub(port, serverWriter);
|
|
//server.BindAddress = IPAddress.Parse("10.42.0.1");
|
|
|
|
systemWriter.WriteLine("Server booting complete. Beginning async loop.");
|
|
//AsyncTools.ForgetTask(beacon.Emit());
|
|
try {
|
|
Task.WaitAll(new Task[] {
|
|
beacon.Emit(),
|
|
server.Listen()
|
|
});
|
|
}
|
|
catch(AggregateException error) {
|
|
foreach (Exception innerErr in error.InnerExceptions)
|
|
Console.WriteLine(innerErr);
|
|
}
|
|
}
|
|
}
|
|
}
|