public static void HostRunFrame_Client(bool frameFinished) { if ((_clientState.NetChannel != null && _clientState.NetChannel.IsTimedOut()) && frameFinished && _clientState.IsConnected()) { Console.WriteLine("Server connection timed out."); // TODO: Show dialog _clientState.Disconnect(true); return; } if (_clientState.NetChannel != null && _clientState.NetChannel.IsTimingOut()) { Console.Title = string.Format("Timing out: {0:####.##}", _clientState.NetChannel.GetTimeoutSeconds() - _clientState.NetChannel.GetTimeSinceLastReceived()); } _clientState.RunFrame(); }
private static void Main(string[] args) { Console.Title = "Envium client"; ClientName = "Draiget"; ServerPassword = ""; _clientState = new ClientState(); _socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); _socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); _socket.Bind(new IPEndPoint(IPAddress.Any, 0)); Networking.Initialize(); _clientState.Initialize(_socket); IntervalPerTick = GetTickInterval(); new Thread(NetTick) { IsBackground = true }.Start(); new Thread(GameTick) { IsBackground = true }.Start(); Console.WriteLine(">> Ready for commands."); var read = string.Empty; while ((read = Console.ReadLine()) != "exit") { if (read != null && read.StartsWith("connect")) { _clientState.Connect(read.Substring(8)); continue; } if (read != null && read.StartsWith("disconnect")) { _clientState.Disconnect(true); continue; } Console.WriteLine("Unknown command \"{0}\".", read); } }