private void processTick(object[] args) { // Check if any clients have timed out foreach (Client c in clients) { if (c.CurrentState == ConnectionState.Play) { // TODO: Check for keep alive timeouts } else { if ((DateTime.Now - c.CreationTime) >= TimeoutPeriod) { ServerThread.Queue((object[] a) => { c.Disconnect(DisconnectReason.TimedOutDuringHandshakeOrLogin); }); } } } TimeSpan sinceLastTick = DateTime.Now - lastTick; TickInfo ti = new TickInfo(); ti.TimeSinceLastTick = sinceLastTick; OnServerTick?.Invoke(ti); lastTick = DateTime.Now; }
private void onClientAccept(IAsyncResult result) { TcpClient c = tcpServer.EndAcceptTcpClient(result); ServerThread.Queue(completeAcceptClient, c); tcpServer.BeginAcceptTcpClient(onClientAccept, null); }
private void onTick(object state) { ServerThread.Queue(processTick); }