コード例 #1
0
        public async Task <GameJoltResponse> SessionOpenAsync()
        {
            if (!WebsiteIsUp)
            {
                var ctor = typeof(GameJoltResponse).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { typeof(string) }, null);
                return((GameJoltResponse)ctor.Invoke(new object[] { "Website is down!" }));
            }

            var openRequest = RequestProvider.Sessions.Open(Username, Token);
            await Client.ExecuteRequestAsync(openRequest);

            if (openRequest.Response.Success)
            {
                _lastSessionPing = DateTime.UtcNow;
            }
            else
            {
                _lastSessionPing = null;
            }

            if (openRequest.Response.Success)
            {
                var request = RequestProvider.Storage.GetKeys(Username, Token);
                await OldClient.ExecuteRequestAsync(request);
            }

            return(openRequest.Response);
        }
コード例 #2
0
        public async Task MigrateAsync()
        {
            var userRequest = RequestProvider.Users.Fetch(Username);
            await Client.ExecuteRequestAsync(userRequest);



            var keysRequest = RequestProvider.Storage.GetKeys(Username, Token);
            await OldClient.ExecuteRequestAsync(keysRequest).ConfigureAwait(false);

            var keyDictionary = new Dictionary <string, string>();

            foreach (var key in keysRequest.Response.Keys)
            {
                var keyRequest = RequestProvider.Storage.Fetch(key, Username, Token);
                await OldClient.ExecuteRequestAsync(keyRequest).ConfigureAwait(false);

                keyDictionary.Add(key, keyRequest.Response.Data);
            }

            foreach (var keyValuePair in keyDictionary)
            {
                var keyRequest = RequestProvider.Storage.Set(keyValuePair.Key, keyValuePair.Value, Username, Token);
                await Client.ExecuteRequestAsync(keyRequest).ConfigureAwait(false);
            }


            var emblemRequest = RequestProvider.Storage.Fetch($"saveStorageV1|{userRequest.Response.Users[0].Id}|emblem", Username, Token);
            var genderRequest = RequestProvider.Storage.Fetch($"saveStorageV1|{userRequest.Response.Users[0].Id}|gender", Username, Token);
            var pointsRequest = RequestProvider.Storage.Fetch($"saveStorageV1|{userRequest.Response.Users[0].Id}|points", Username, Token);
            await OldClient.ExecuteRequestAsync(emblemRequest).ConfigureAwait(false);

            await OldClient.ExecuteRequestAsync(genderRequest).ConfigureAwait(false);

            await OldClient.ExecuteRequestAsync(pointsRequest).ConfigureAwait(false);

            var emblemRequest1 = RequestProvider.Storage.Set($"saveStorageV1|{userRequest.Response.Users[0].Id}|emblem", emblemRequest.Response.Data, Username, Token);
            var genderRequest1 = RequestProvider.Storage.Set($"saveStorageV1|{userRequest.Response.Users[0].Id}|gender", genderRequest.Response.Data, Username, Token);
            var pointsRequest1 = RequestProvider.Storage.Set($"saveStorageV1|{userRequest.Response.Users[0].Id}|points", pointsRequest.Response.Data, Username, Token);
            await Client.ExecuteRequestAsync(emblemRequest1).ConfigureAwait(false);

            await Client.ExecuteRequestAsync(genderRequest1).ConfigureAwait(false);

            await Client.ExecuteRequestAsync(pointsRequest1).ConfigureAwait(false);


            var migratedRequest = RequestProvider.Storage.Set($"saveStorageV1|{userRequest.Response.Users[0].Id}|migrated", "", Username, Token);
            await OldClient.ExecuteRequestAsync(migratedRequest).ConfigureAwait(false);
        }
コード例 #3
0
        public async Task <bool> IsMigratedAsync()
        {
            if (!await IsConnectedAsync() || !WebsiteIsUp)
            {
                return(false);
            }

            var userRequest = RequestProvider.Users.Fetch(Username);
            await Client.ExecuteRequestAsync(userRequest);

            if (userRequest.Response?.Users?.Any() == null)
            {
                return(false);
            }

            var request = RequestProvider.Storage.Fetch($"saveStorageV1|{userRequest.Response.Users[0].Id}|migrated", Username, Token);
            await OldClient.ExecuteRequestAsync(request).ConfigureAwait(false);

            return(request.Response.Success);
        }