示例#1
0
        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;
        }
示例#2
0
        private void onClientAccept(IAsyncResult result)
        {
            TcpClient c = tcpServer.EndAcceptTcpClient(result);

            ServerThread.Queue(completeAcceptClient, c);
            tcpServer.BeginAcceptTcpClient(onClientAccept, null);
        }
示例#3
0
 private void onTick(object state)
 {
     ServerThread.Queue(processTick);
 }