private string GetIP() { JToken IPRequest = JsonDownloader.Get <JToken>("http://ll.leagueoflegends.com/services/connection_info"); if (IPRequest == null || IPRequest["ip_address"] == null) { return("127.0.0.1"); } Form1.Log("IP Address = " + (string)IPRequest["ip_address"]); return((string)IPRequest["ip_address"]); }
private string GetAuthCode(string Username, string Password, string LoginQueue) { NameValueCollection query = new NameValueCollection(); query.Add("payload", string.Format("user={0},password={1}", Username, Password)); JToken login = JsonDownloader.Post <JToken>(LoginQueue + "login-queue/rest/queue/authenticate", query); string Status = (string)login["status"]; if (Status == "FAILED") { throw new Exception("Error logging in: " + (string)login["reason"]); } if (Status == "LOGIN") { Form1.Log("Auth Token = " + login["token"]); return((string)login["token"]); } int node = (int)login["node"]; string champ = (string)login["champ"]; int rate = (int)login["rate"]; int delay = (int)login["delay"]; int id = 0; int cur = 0; JArray tickers = (JArray)login["tickers"]; foreach (JToken token in tickers) { int tnode = (int)token["node"]; if (tnode != node) { continue; } id = (int)token["id"]; cur = (int)token["current"]; break; } Form1.Log("In login queue for " + Region + ", #" + (id - cur) + " in line"); while (id - cur > rate) { Thread.Sleep(delay); JToken result = JsonDownloader.Get <JToken>(LoginQueue + "login-queue/rest/queue/ticker/" + champ); if (result == null) { continue; } cur = Convert.ToInt32((string)result[node.ToString()], 16); Form1.Log("In login queue for " + Region + ", #" + (int)Math.Max(1, id - cur) + " in line"); } JToken login2 = JsonDownloader.Get <JToken>(LoginQueue + "login-queue/rest/queue/authToken/" + Username.ToLower()); while (login2 == null || login2["token"] == null) { Thread.Sleep(delay / 10); login2 = JsonDownloader.Get <JToken>(LoginQueue + "login-queue/rest/queue/authToken/" + Username.ToLower()); } Form1.Log("Auth Token = " + login2["token"]); return((string)login2["token"]); }