Beispiel #1
0
        public async void CanSendRequestViaWebsocket()
        {
            await ChatClient.InitializeWebsocketConnection();

            const string message  = "some random testing message";
            var          response = await ChatClient.AddMessageAsync(message);

            response.Data.AddMessage.Content.Should().Be(message);
        }
Beispiel #2
0
        protected override void _Login(LoginParamValue[] LoginParams)
        {
            try
            {
                string APIKey = "";
                GQLClient = new GraphQL.Client.Http.GraphQLHttpClient(
                    new GraphQLHttpClientOptions {
                    EndPoint = new Uri(URL), OnWebsocketConnected = OnWSConnected
                }, new NewtonsoftJsonSerializer());

                foreach (LoginParamValue x in LoginParams)
                {
                    if (x.Param.Name.ToLower() == "api key")
                    {
                        APIKey = x.Value;
                    }
                }

                GQLClient.HttpClient.DefaultRequestHeaders.Add("x-access-token", APIKey);
                GQLClient.InitializeWebsocketConnection();
                GraphQLRequest LoginReq = new GraphQLRequest
                {
                    Query = "query {user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses betAmount profit currency}}}"
                };
                //var /*GraphQLResponse<pdUser>*/ Resp2 = GQLClient.SendQueryAsync<dynamic>(LoginReq).Result;
                var /*GraphQLResponse<pdUser>*/ Resp = GQLClient.SendQueryAsync <pdUser>(LoginReq).Result;
                pdUser user = Resp.Data.User;
                userid = user.id;
                if (string.IsNullOrWhiteSpace(userid))
                {
                    callLoginFinished(false);
                }
                else
                {
                    foreach (Statistic x in user.statistic)
                    {
                        if (x.currency.ToLower() == Currencies[Currency].ToLower() && x.game == StatGameName)
                        {
                            this.Stats.Bets    = (int)x.bets;
                            this.Stats.Wins    = (int)x.wins;
                            this.Stats.Losses  = (int)x.losses;
                            this.Stats.Profit  = x.profit;
                            this.Stats.Wagered = x.amount;

                            break;
                        }
                    }
                    foreach (Balance x in user.balances)
                    {
                        if (x.available.currency.ToLower() == Currencies[Currency].ToLower())
                        {
                            this.Stats.Balance = x.available.amount;
                            break;
                        }
                    }

                    callLoginFinished(true);
                    return;
                }
            }
            catch (WebException e)
            {
                Logger.DumpLog(e);
                if (e.Response != null)
                {
                }
                callLoginFinished(false);
            }
            catch (Exception e)
            {
                Logger.DumpLog(e);
                callLoginFinished(false);
            }
        }