/// <summary> /// Retrieves Quake Live server data from a public filter URL. /// </summary> /// <param name="filter">The base64 encoded json filter.</param> /// <returns>The server data as a root <see cref="FilterObject"/></returns> public async Task <FilterObject> GetServerDataFromFilter(string filter) { if (string.IsNullOrEmpty(filter)) { Log.Write("No encoded filter was specified!", _logClassType, _logPrefix); return(null); } try { var query = new RestApiQuery(); var url = string.Format("http://www.quakelive.com/browser/list?filter={0}&_={1}", filter, Math.Truncate((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds)); var filterObj = await(query.QueryRestApiAsync <FilterObject>(url)); if (filterObj != null) { Log.Write("Got filter information for base64 encoded filter.", _logClassType, _logPrefix); } return(filterObj); } catch (Exception ex) { Log.WriteCritical("Problem retrieving filter object from encoded filter: " + ex.Message, _logClassType, _logPrefix); return(null); } }
/// <summary> /// Queries a Quake Live server. /// </summary> /// <param name="serverId">The server identifier.</param> /// <returns>The server's details as a <see cref="Server"/> object.</returns> public async Task <Server> QueryQlServer(string serverId) { if (string.IsNullOrEmpty(serverId)) { Log.Write("No server ID was specified!", _logClassType, _logPrefix); return(null); } try { var query = new RestApiQuery(); var url = "http://www.quakelive.com/browser/details?ids=" + serverId; var serverList = await(query.QueryRestApiAsync <IList <Server> >(url)); // QL always returns a collection no matter what. We're only querying one server so // get first. if (serverList.Count != 0) { Log.Write(string.Format("Got server information for server with id {0}", serverId), _logClassType, _logPrefix); } return(serverList.First()); } catch (Exception ex) { Log.WriteCritical("Problem returning server information: " + ex.Message, _logClassType, _logPrefix); return(null); } }
/// <summary> /// Asynchronously retrieves the player Elo information from the QLRanks API via HTTP GET request(s). /// </summary> /// <param name="players">The players.</param> /// <returns>QLRanks object</returns> private async Task <QlRanks> GetEloDataFromQlRanksApiAsync(string players) { var url = "http://www.qlranks.com/api.aspx?nick=" + players; //var url = "http://10.0.0.7/api.aspx?nick=" + players; try { var query = new RestApiQuery(); var qlr = await(query.QueryRestApiAsync <QlRanks>(url)); return(qlr); } catch (Exception e) { Log.WriteCritical("Unable to retrieve QLRanks data from remote API: " + e.Message, _logClassType, _logPrefix); return(null); } }