示例#1
0
 private GameClientWorkerJob(string baseAddress, int index, WorkerThreadResult workerThreadResult, IRequestSequence requestSequence, TrackedApiClient client)
 {
     _baseAddress        = baseAddress;
     _index              = index;
     _workerThreadResult = workerThreadResult;
     _requestSequence    = requestSequence;
     _client             = client;
     //_gameRequestSequence = new GameRequestSequence(_baseAddress, _index, _workerThreadResult);
 }
示例#2
0
        public static async Task <TrackedApiClient> NewGuestAsync(int index, WorkerThreadResult workerThreadResult, string baseAddress)
        {
            ApiClient.SerializationModel = Generator.Generate(new[]
            {
                typeof(UserLoginResponse).GetTypeInfo().Assembly,
                typeof(Picasso.Common.PicassoDto).GetTypeInfo().Assembly
            });
            var unauthenticated = new TrackedApiClient(index, workerThreadResult, baseAddress, null);

            var res = await unauthenticated.PostAsync <UserLoginResponse>("users", new UserCreateRequest
            {
                AutoGenerateName = true,
                SsoToken         = Guid.NewGuid().ToString("n"),
            });

            res.AssertSuccessful();
            return(new TrackedApiClient(index, workerThreadResult, baseAddress, new ApiContext
            {
                SessionToken = res.Data.SecretKey
            }));
        }
示例#3
0
        public async Task StartSequence()
        {
            var client = await TrackedApiClient.NewGuestAsync(_index, _workerThreadResult, _baseAddress);

            var gameStartResponse = await client.PostAsync <GameStartResponse>($"game/start", new GameStartRequest
            {
                Mode  = ControlMode.Smart,
                Goals = new List <GoalDto>
                {
                    new GoalDto
                    {
                        Name     = "Destroy",
                        Required = 10
                    }
                }
            });

            var gameStopResponse = await client.PostAsync <EndGameResponse>($"game/stop", new GameEndRequest
            {
                GameId = gameStartResponse.Data.GameId,
                Level  = 1
            });
        }
示例#4
0
 public Task <IWorkerJob> Init(int index, WorkerThreadResult workerThreadResult)
 {
     _client = new TrackedApiClient(index, workerThreadResult, _baseAddress);
     _requestSequence.Register(_client);
     return(Task.FromResult <IWorkerJob>(new GameClientWorkerJob(_baseAddress, index, workerThreadResult, _requestSequence, _client)));
 }