/// <summary> /// Convert a SourceQueryInfo object from CoreRcon to a SteamServerInfo object /// </summary> /// <param name="info">SourceQueryInfo</param> /// <returns>SteamServerInfo</returns> private SteamServerInfo ConvertInfoResponse(SourceQueryInfo info) { _logger.LogDebug("Converting SourceQueryInfo to SteamServerInfo"); return(new SteamServerInfo() { Game = info.Game, Map = info.Map, MaxPlayers = info.MaxPlayers, CurrentPlayers = info.Players, Bots = info.Bots, Environment = info.Environment, Folder = info.Folder, GameId = info.GameId, Name = info.Name, ProtocolVersion = info.ProtocolVersion, Type = info.Type, VAC = info.VAC, Visibility = info.Visibility }); }
/// <summary> /// Get information about the server. /// </summary> /// <param name="host">Endpoint of the server.</param> public static async Task <IQueryInfo> Info(IPEndPoint host, ServerType type) { switch (type) { case ServerType.Source: await _client.SendAsync(new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0x54, 0x53, 0x6F, 0x75, 0x72, 0x63, 0x65, 0x20, 0x45, 0x6E, 0x67, 0x69, 0x6E, 0x65, 0x20, 0x51, 0x75, 0x65, 0x72, 0x79, 0x00 }, 25, host); var sourceResponse = await _client.ReceiveAsync(); return(SourceQueryInfo.FromBytes(sourceResponse.Buffer)); case ServerType.Minecraft: var padding = new byte[] { 0x00, 0x00, 0x00, 0x00 }; var datagram = _magic.Concat(new[] { (byte)PacketType.Stat }).Concat(_sessionid).Concat(await Challenge(host, ServerType.Minecraft)).Concat(padding).ToArray(); await _client.SendAsync(datagram, datagram.Length, host); var mcResponce = await _client.ReceiveAsync(); return(MinecraftQueryInfo.FromBytes(mcResponce.Buffer)); default: throw new ArgumentException("type argument was invalid"); } }