void GetBalanceThread() { try { while (iscg) { if (accesstoken != "" && ((DateTime.Now - lastupdate).TotalSeconds > 60 || ForceUpdateStats)) { lastupdate = DateTime.Now; try { string sEmitResponse = Client.GetStringAsync("user/" + Currency + "/" + accesstoken).Result; cgUser tmpBal = json.JsonDeserialize <cgUser>(sEmitResponse); this.balance = tmpBal.Balance; this.wagered = tmpBal.Wagered; this.profit = tmpBal.Profit; this.bets = tmpBal.TotalBets; edge = tmpBal.DiceEdge; Parent.updateBalance((decimal)(balance)); Parent.updateBets(bets); Parent.updateLosses(losses); Parent.updateProfit(profit); Parent.updateWagered(wagered); Parent.updateWins(wins); } catch { } } Thread.Sleep(1000); } } catch { } }
public override void Login(string Username, string Password, string twofa) { ClientHandlr = new HttpClientHandler { UseCookies = true, AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip, Proxy = this.Prox, UseProxy = Prox != null }; Client = new HttpClient(ClientHandlr) { BaseAddress = new Uri("https://api.crypto.games/v1/") }; Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("gzip")); Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("deflate")); try { accesstoken = Password; string sEmitResponse = Client.GetStringAsync("user/" + Currency + "/" + accesstoken).Result; cgUser tmpBal = json.JsonDeserialize <cgUser>(sEmitResponse); sEmitResponse = Client.GetStringAsync("nextseed/" + Currency + "/" + accesstoken).Result; cgNextSeed tmpSeed = json.JsonDeserialize <cgNextSeed>(sEmitResponse); CurrenyHash = tmpSeed.NextServerSeedHash; this.balance = tmpBal.Balance; this.wagered = tmpBal.Wagered; this.profit = tmpBal.Profit; this.bets = tmpBal.TotalBets; //Get stats //assign vals to stats edge = tmpBal.DiceEdge; Parent.updateBalance((decimal)(balance)); Parent.updateBets(bets); Parent.updateLosses(losses); Parent.updateProfit(profit); Parent.updateWagered(wagered); Parent.updateWins(wins); Thread t = new Thread(GetBalanceThread); iscg = true; t.Start(); finishedlogin(true); } catch (AggregateException e) { Parent.DumpLog(e.ToString(), -1); finishedlogin(false); } catch (Exception e) { Parent.DumpLog(e.ToString(), -1); finishedlogin(false); } }