void IntroduceNewClients(ClientAcceptor acceptor) { TcpClient client; while ((client = acceptor.PullClient()) != null) { var remoteClient = new RemoteClient(client, Command.Deserialize); Log("Client connected: {0}", remoteClient.RemoteEndPoint); remoteClient.WriteMessages(_world.InstantState); _remoteClients.Add(remoteClient); } }
public void Execute() { var acceptor = new ClientAcceptor(endPoint); var clientCommands = new List <Command>(); while (true) { IntroduceNewClients(acceptor); RemoveDisconnectedClients(); FetchClientCommands(clientCommands); var stateDelta = _world.Simulate(clientCommands); clientCommands.Clear(); SendToClients(stateDelta); Thread.Sleep(1000 / Consts.STEPS_PER_SECOND); } }