Example #1
0
        protected override void _Login(LoginParamValue[] LoginParams)
        {
            System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
            ClientHandlr = new HttpClientHandler {
                UseCookies = true, AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip
            };
            ClientHandlr.CookieContainer = new CookieContainer();
            Client = new HttpClient(ClientHandlr)
            {
                BaseAddress = new Uri("https://duckdice.io/api/")
            };
            Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("gzip"));
            Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("deflate"));
            Client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0");
            try
            {
                accesstoken = LoginParams[0].Value;


                string       sEmitResponse = Client.GetStringAsync("load/" + CurrentCurrency + "?api_key=" + accesstoken).Result;
                Quackbalance balance       = json.JsonDeserialize <Quackbalance>(sEmitResponse);
                sEmitResponse = Client.GetStringAsync("stat/" + CurrentCurrency + "?api_key=" + accesstoken).Result;
                QuackStatsDetails _Stats = json.JsonDeserialize <QuackStatsDetails>(sEmitResponse);
                sEmitResponse = Client.GetStringAsync("randomize" + "?api_key=" + accesstoken).Result;
                currentseed   = json.JsonDeserialize <QuackSeed>(sEmitResponse).current;
                if (balance != null && _Stats != null)
                {
                    Stats.Balance = decimal.Parse(balance.user.balance, System.Globalization.NumberFormatInfo.InvariantInfo);
                    Stats.Profit  = decimal.Parse(_Stats.profit, System.Globalization.NumberFormatInfo.InvariantInfo);
                    Stats.Wagered = decimal.Parse(_Stats.volume, System.Globalization.NumberFormatInfo.InvariantInfo);
                    Stats.Bets    = _Stats.bets;
                    Stats.Wins    = _Stats.wins;
                    Stats.Losses  = _Stats.bets - _Stats.wins;


                    ispd       = true;
                    lastupdate = DateTime.Now;
                    new Thread(new ThreadStart(GetBalanceThread)).Start();
                    callLoginFinished(true);
                    return;
                }
            }
            catch (Exception e)
            {
                callLoginFinished(false);
                return;
            }
            callLoginFinished(false);
            return;
        }
Example #2
0
 protected override void _UpdateStats()
 {
     try
     {
         string       sEmitResponse = Client.GetStringAsync("load/" + CurrentCurrency + "?api_key=" + accesstoken).Result;
         Quackbalance balance       = json.JsonDeserialize <Quackbalance>(sEmitResponse);
         Stats.Balance = decimal.Parse(balance.user.balance, System.Globalization.NumberFormatInfo.InvariantInfo);
         sEmitResponse = Client.GetStringAsync("stat/" + CurrentCurrency + "?api_key=" + accesstoken).Result;
         QuackStatsDetails _Stats = json.JsonDeserialize <QuackStatsDetails>(sEmitResponse);
         Stats.Profit  = decimal.Parse(_Stats.profit, System.Globalization.NumberFormatInfo.InvariantInfo);
         Stats.Wagered = decimal.Parse(_Stats.volume, System.Globalization.NumberFormatInfo.InvariantInfo);
         Stats.Bets    = _Stats.bets;
         Stats.Wins    = _Stats.wins;
         Stats.Losses  = _Stats.bets - _Stats.wins;
     }
     catch
     {
     }
 }