public static void RunInit() { if (Settings.IsEmpty()) { throw new ArgumentNullException(nameof(Settings)); } ConnectedClients = new Dictionary <Guid, Client>(); ConnectionListener = new TcpListener(new IPEndPoint(IPAddress.Any, Settings.Port)); ConnectionListener.Start(); PingService = new PingService(new Dictionary <Guid, Client>()); PingService.Start(); MainLoopTask = new Action(() => { while (!MainLoopAbort) { try { TcpConnection conn = (TcpConnection)ConnectionListener.AcceptTcpClient(); Console.WriteLine("[MasterListener] accept connection"); // Spawn a new PacketListenerLoop PacketListenerLoop.Spawn(conn, new Server_PacketHandler(conn)); } catch (Exception e) { Console.WriteLine(e.Message); } } }); MainLoopAbort = false; //Run Task.Run(MainLoopTask); Console.WriteLine("Listening for connections..."); }
public void Start() { ps.NewResultAvailable += NewResultAvailable; ps.RequestProcessed += ExtReqsUpdated; Host1name = ps.Hosts[0].ToString(); Host2name = ps.Hosts[1].ToString(); ps.Start(); }