Beispiel #1
0
 void WSClient_MessageReceived(object sender, MessageReceivedEventArgs e)
 {
     Parent.DumpLog(e.Message, 10);
     if (e.Message == "3probe")
     {
         WSClient.Send("5");
         WSClient.Send("42" + id++ + "[\"get_hash\",null]");
         string Bet = string.Format(
             System.Globalization.NumberFormatInfo.InvariantInfo,
             "42{0}[\"access_token_data\",{{\"app_id\":{1},\"access_token\":\"{2}\",\"currency\":\"{3}\"}}]",
             id++,
             APPId,
             accesstoken,
             Currency
             );
         WSClient.Send(Bet);
     }
     else
     {
         if (e.Message.Contains("[null,{\"bet_hash\":"))
         {
             string msg = e.Message.Substring(e.Message.IndexOf("{"));
             msg = msg.Substring(0, msg.Length - 1);
             SDiceHash tmphash = json.JsonDeserialize <SDiceHash>(msg);
             this.OldHash = tmphash.bet_hash;
         }
         if (e.Message.Contains("[null,{\"token\":"))
         {
             string msg = e.Message.Substring(e.Message.IndexOf("{"));
             msg = msg.Substring(0, msg.Length - 1);
             SDIceAccToken tmphash = json.JsonDeserialize <SDIceAccToken>(msg);
             this.balance = (Currency.ToLower() == "btc"? tmphash.user.balances.btc:
                             Currency.ToLower() == "ltc" ? tmphash.user.balances.ltc :
                             Currency.ToLower() == "dash" ? tmphash.user.balances.dash :
                             0
                             ) / 100000000m;
             this.profit  = tmphash.user.betted_profit / 100000000m;
             this.wagered = tmphash.user.betted_wager / 100000000m;
             this.bets    = (int)tmphash.user.betted_count;
             Parent.updateBalance(balance);
             Parent.updateProfit(profit);
             Parent.updateWagered(wagered);
             Parent.updateBets(bets);
         }
         if (e.Message.Contains("[null,{\"auth_id\":"))
         {
             string msg = e.Message.Substring(e.Message.IndexOf("{"));
             msg = msg.Substring(0, msg.Length - 1);
             sdiceauth tmphash = json.JsonDeserialize <sdiceauth>(msg);
             this.balance = (Currency.ToLower() == "btc" ? tmphash.user.balances.btc :
                             Currency.ToLower() == "ltc" ? tmphash.user.balances.ltc :
                             Currency.ToLower() == "dash" ? tmphash.user.balances.dash :
                             0
                             ) / 100000000m;
             this.profit  = tmphash.user.betted_profit / 100000000m;
             this.wagered = tmphash.user.betted_wager / 100000000m;
             this.bets    = (int)tmphash.user.betted_count;
             Parent.updateBalance(balance);
             Parent.updateProfit(profit);
             Parent.updateWagered(wagered);
             Parent.updateBets(bets);
         }
         if (e.Message.Contains("[null,{\"id\":"))
         {
             //do bet
             string msg = e.Message.Substring(e.Message.IndexOf("{"));
             msg = msg.Substring(0, msg.Length - 1);
             SDIceBet tmphash = json.JsonDeserialize <SDIceBet>(msg);
             if (tmphash.bet_id > 0)
             {
                 Bet newbet = new Bet
                 {
                     Amount     = amount,
                     date       = DateTime.Now,
                     Chance     = chance,
                     high       = High,
                     clientseed = ClientSeed,
                     Id         = tmphash.bet_id.ToString(),
                     nonce      = 0,
                     serverseed = tmphash.secret,//tmphash.salt,
                     serverhash = OldHash,
                     Profit     = tmphash.profit / 100000000m,
                     Roll       = decimal.Parse(tmphash.outcome, System.Globalization.NumberFormatInfo.InvariantInfo),
                     Guid       = this.Guid
                 };
                 OldHash  = tmphash.next_hash;
                 balance += newbet.Profit;
                 profit  += newbet.Profit;
                 bets++;
                 wagered += newbet.Amount;
                 bool win = false;
                 if ((newbet.Roll > maxRoll - newbet.Chance && High) || (newbet.Roll < newbet.Chance && !High))
                 {
                     win = true;
                 }
                 if (win)
                 {
                     wins++;
                 }
                 else
                 {
                     losses++;
                 }
                 FinishedBet(newbet);
             }
         }
     }
 }
Beispiel #2
0
 void WSClient_MessageReceived(object sender, MessageReceivedEventArgs e)
 {
     //Parent.DumpLog(e.Message, -1);
     if (e.Message == "3probe")
     {
         WSClient.Send("5");
         //4214["access_token_data",{"app_id":2668,"access_token":"49af40dd-5f96-4c67-ab16-6ff05f0d364b"}]
         //20:421["get_hash",null]
         WSClient.Send("42" + id++ + "[\"get_hash\",null]");
         string getbalance = string.Format("42{0}[\"access_token_data\",{{\"app_id\":{1},\"access_token\":\"{2}\"}}]", id++, APPId, accesstoken);
         WSClient.Send(getbalance);
         //148:420["chat_init",{"app_id":926,"access_token":"5ed59498-d425-4c63-835e-348f56753d5a","subscriptions":["CHAT","DEPOSITS","BETS"],"room":"ENGLISH_RM"}]
     }
     else
     {
         if (e.Message.Contains("[null,{\"hash\":"))
         {
             //431[null,{"hash":"60a4fb16aa9aa7020d6adc397730952d102adde98428007701836dcb5e4c48eb","bet_hash":"60a4fb16aa9aa7020d6adc397730952d102adde98428007701836dcb5e4c48eb"}]
             string msg = e.Message.Substring(e.Message.IndexOf("{"));
             msg = msg.Substring(0, msg.Length - 1);
             SDiceHash tmphash = json.JsonDeserialize <SDiceHash>(msg);
             this.OldHash = tmphash.bet_hash;
         }
         if (e.Message.Contains("[null,{\"token\":"))
         {
             // get balance and stats
             string msg = e.Message.Substring(e.Message.IndexOf("{"));
             msg = msg.Substring(0, msg.Length - 1);
             SDIceAccToken tmphash = json.JsonDeserialize <SDIceAccToken>(msg);
             this.balance = tmphash.auth.user.balance / 100000000m;
             this.profit  = tmphash.auth.user.betted_profit / 100000000m;
             this.wagered = tmphash.auth.user.betted_wagered / 100000000m;
             this.bets    = (int)tmphash.auth.user.betted_count;
             Parent.updateBalance(balance);
             Parent.updateProfit(profit);
             Parent.updateWagered(wagered);
             Parent.updateBets(bets);
         }
         if (e.Message.Contains("[null,{\"id\":"))
         {
             //do bet
             string msg = e.Message.Substring(e.Message.IndexOf("{"));
             msg = msg.Substring(0, msg.Length - 1);
             SDIceBet tmphash = json.JsonDeserialize <SDIceBet>(msg);
             Bet      newbet  = new Bet
             {
                 Amount     = amount,
                 date       = DateTime.Now,
                 Chance     = chance,
                 high       = High,
                 clientseed = ClientSeed,
                 Id         = tmphash.bet_id.ToString(),
                 nonce      = tmphash.secret,
                 serverseed = tmphash.salt,
                 serverhash = OldHash,
                 Profit     = tmphash.profit / 100000000m,
                 Roll       = decimal.Parse(tmphash.outcome, System.Globalization.NumberFormatInfo.InvariantInfo)
             };
             OldHash  = tmphash.next_hash;
             balance += newbet.Profit;
             profit  += newbet.Profit;
             bets++;
             wagered += newbet.Amount;
             bool win = false;
             if ((newbet.Roll > maxRoll - newbet.Chance && High) || (newbet.Roll < newbet.Chance && !High))
             {
                 win = true;
             }
             if (win)
             {
                 wins++;
             }
             else
             {
                 losses++;
             }
             FinishedBet(newbet);
         }
     }
 }