Exemple #1
0
 void GetBalanceThread()
 {
     try
     {
         while (ispd)
         {
             if (accesstoken != "" && ((DateTime.Now - lastupdate).TotalSeconds > 60 || ForceUpdateStats))
             {
                 ForceUpdateStats = false;
                 lastupdate       = DateTime.Now;
                 string       sEmitResponse2 = Client.GetStringAsync("api/stats").Result;
                 NDGetBalance tmpu           = json.JsonDeserialize <NDGetBalance>(sEmitResponse2);
                 try
                 {
                     sEmitResponse2 = Client.GetStringAsync("sshash").Result;
                     NDGetHash tmpHash = json.JsonDeserialize <NDGetHash>(sEmitResponse2);
                     lastHash = tmpHash.sshash;
                 }
                 catch (Exception e)
                 {
                 }
                 balance = tmpu.balance;
                 profit  = tmpu.amountLost + tmpu.amountWon;
                 wins    = (int)tmpu.totWins;
                 losses  = (int)tmpu.totLosses;
                 bets    = (int)tmpu.totBets;
                 Parent.updateBalance((balance));
                 Parent.updateBets(bets);
                 Parent.updateWins(wins);
                 Parent.updateLosses(losses);
                 Parent.updateProfit(profit);
             }
             Thread.Sleep(1000);
         }
     }
     catch
     {
     }
 }
Exemple #2
0
        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://www.nitrodice.com/")
            };
            Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("gzip"));
            Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("deflate"));


            try
            {
                string jsoncontent = json.JsonSerializer <NDAuth>(new NDAuth()
                {
                    pass = Password, user = Username, tfa = twofa
                });
                StringContent Content  = new StringContent(jsoncontent, Encoding.UTF8, "application/json");
                string        Response = Client.PostAsync("api/auth", Content).Result.Content.ReadAsStringAsync().Result;
                NDGetAuth     getauth  = json.JsonDeserialize <NDGetAuth>(Response);
                if (getauth != null)
                {
                    if (getauth.token != null)
                    {
                        Client.DefaultRequestHeaders.Add("x-token", getauth.token);
                        Client.DefaultRequestHeaders.Add("x-user", Username);
                        accesstoken = getauth.token;
                        CurrencyChanged();
                        string       sEmitResponse2 = Client.GetStringAsync("api/stats").Result;
                        NDGetBalance tmpu           = json.JsonDeserialize <NDGetBalance>(sEmitResponse2);
                        try
                        {
                            sEmitResponse2 = Client.GetStringAsync("sshash").Result;
                            NDGetHash tmpHash = json.JsonDeserialize <NDGetHash>(sEmitResponse2);
                            lastHash = tmpHash.sshash;
                        }
                        catch (Exception e)
                        {
                        }
                        balance = tmpu.balance;
                        profit  = tmpu.amountLost + tmpu.amountWon;
                        wins    = (int)tmpu.totWins;
                        losses  = (int)tmpu.totLosses;
                        bets    = (int)tmpu.totBets;
                        Parent.updateBalance((balance));
                        Parent.updateBets(bets);
                        Parent.updateWins(wins);
                        Parent.updateLosses(losses);
                        Parent.updateProfit(profit);
                        lastupdate = DateTime.Now;
                        ispd       = true;
                        Thread t = new Thread(GetBalanceThread);
                        t.Start();
                        finishedlogin(true);
                        return;
                    }
                }
            }
            catch (Exception e)
            {
                Parent.DumpLog(e.ToString(), -1);
            }
            finishedlogin(false);
        }