protected override void _UpdateStats() { LastBalance = DateTime.Now; string sEmitResponse = Client.GetStringAsync("userbalance/?ctoken=" + accesstoken).Result; SatBalance tmpbal = json.JsonDeserialize <SatBalance>(sEmitResponse); Stats.Balance = tmpbal.balanceInSatoshis / 100000000.0m; LastBalance = DateTime.Now; }
protected override void _Login(LoginParamValue[] LoginParams) { string email = "", Password = ""; foreach (LoginParamValue x in LoginParams) { switch (x.Param.Name.ToLower()) { case "email": email = x.Value; break; case "password": Password = x.Value; break; } } ClientHandlr = new HttpClientHandler { UseCookies = true, AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip }; Client = new HttpClient(ClientHandlr) { BaseAddress = new Uri("https://session.megadice.com/userapi/") }; Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("gzip")); Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("deflate")); try { List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >(); pairs.Add(new KeyValuePair <string, string>("email", email)); pairs.Add(new KeyValuePair <string, string>("password", Password)); FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs); string sEmitResponse = Client.PostAsync("login.php", Content).Result.Content.ReadAsStringAsync().Result; SatDiceLogin tmplog = json.JsonDeserialize <SatDiceLogin>(sEmitResponse); if (tmplog.message.ToLower() == "login successful.") { accesstoken = tmplog.ctoken; sEmitResponse = Client.GetStringAsync("useraddress/?ctoken=" + accesstoken).Result; SatDepAddress tmpDep = json.JsonDeserialize <SatDepAddress>(sEmitResponse); sEmitResponse = Client.GetStringAsync("userbalance/?ctoken=" + accesstoken).Result; SatBalance tmpbal = json.JsonDeserialize <SatBalance>(sEmitResponse); sEmitResponse = Client.GetStringAsync("startround/?ctoken=" + accesstoken).Result; SatGameRound tmpgame = json.JsonDeserialize <SatGameRound>(sEmitResponse); curHash = tmpgame.hash; GameID = tmpgame.id; if (GameID > 0 && curHash != "") { Stats.Balance = ((decimal)tmpbal.balanceInSatoshis / 100000000m); IsSatDice = true; new System.Threading.Thread(new System.Threading.ThreadStart(GetBalanceThread)).Start(); callLoginFinished(true); return; } } else { callLoginFinished(false); return; } } catch { } callLoginFinished(true); }