internal static GameServerInfo Parse(IGameServer server, ushort ping, BufferReader reader) { var result = new GameServerInfo { Server = server, ProtocolVersion = reader.ReadByte(), Name = reader.ReadString(), Map = reader.ReadString(), Gamedir = reader.ReadString(), Game = reader.ReadString(), AppId = reader.ReadShort(), Players = reader.ReadByte(), MaxPlayers = reader.ReadByte(), Bots = reader.ReadByte(), Type = ReadType(reader), Environment = ReadEnvironment(reader), HasPassword = reader.ReadBool(), Vac = reader.ReadBool(), Version = reader.ReadString(), Ping = ping }; return(result); }
internal static GameServerInfo Parse(IGameServer server, ushort ping, BufferReader reader) { var result = new GameServerInfo { Server = server, ProtocolVersion = reader.ReadByte(), Name = reader.ReadString(), Map = reader.ReadString(), Gamedir = reader.ReadString(), Game = reader.ReadString(), AppId = reader.ReadShort(), Players = reader.ReadByte(), MaxPlayers = reader.ReadByte(), Bots = reader.ReadByte(), Type = ReadType(reader), Environment = ReadEnvironment(reader), HasPassword = reader.ReadBool(), Vac = reader.ReadBool(), Version = reader.ReadString(), Ping = ping }; return result; }
private async Task<GameServerInfo> QueryServerInfoAsync(TimeSpan timeout) { var task = Task.Run(async () => { using (var client = SteamAgent.GetUdpClient(EndPoint)) { var requestPacket = GetRequestPacket(GameServerQueryPacketType.InfoRequest); requestPacket.WriteString("Source Engine Query"); var pingTask = SendPing(); var responseTask = SteamAgent.RequestResponseAsync(client, requestPacket.ToArray(), 4); await Task.WhenAll(pingTask, responseTask); var response = await responseTask; var ping = await pingTask; var responseType = response.ReadEnum<GameServerQueryPacketType>(); if (responseType != GameServerQueryPacketType.InfoResponse) throw new ProtocolViolationException(); _info = GameServerInfo.Parse(this, ping, response); return _info; } }); return await task.TimeoutAfter(timeout); }