public string GetWebSession() { if (Username == null || Key == null) { throw new Exception("Can't get session, not logged in!"); } if (!TheClient.CVars.n_online.ValueB) { return("NO_SESSION"); } NameValueCollection data = new NameValueCollection(); using (ShortWebClient wb = new ShortWebClient()) { data["qtype"] = "one_use_key"; data["username"] = Username; data["SType"] = "voxalia"; data["sess_key"] = Key; byte[] response = wb.UploadValues(VoxProgram.GlobalServerAddress, "POST", data); string resp = FileHandler.DefaultEncoding.GetString(response).Trim(' ', '\n', '\r', '\t'); if (resp.StartsWith("ACCEPT=") && resp.EndsWith(";")) { return(resp.Substring("ACCEPT=KEY/".Length, resp.Length - 1 - "ACCEPT=KEY/".Length)); } throw new Exception("Failed to get session: " + resp); } }
public string GetWebSession() { if (Username == null || Key == null) { throw new Exception("Can't get session, not logged in!"); } if (!TheClient.CVars.n_online.ValueB) { return "NO_SESSION"; } using (ShortWebClient wb = new ShortWebClient()) { NameValueCollection data = new NameValueCollection(); data["formtype"] = "getsess"; data["username"] = Username; data["session"] = Key; byte[] response = wb.UploadValues(Program.GlobalServerAddress + "account/microgetsess", "POST", data); string resp = FileHandler.encoding.GetString(response).Trim(' ', '\n', '\r', '\t'); if (resp.StartsWith("ACCEPT=") && resp.EndsWith(";")) { return resp.Substring("ACCEPT=".Length, resp.Length - 1 - "ACCEPT=".Length); } throw new Exception("Failed to get session: " + resp); } }