public GameStateMachinePlayer(PlanetWarsServerSettings settings, int playerId, ApiPlayerRole role, InternalLogger internalLogger, CancellationToken cancellationToken)
        {
            this.settings            = settings;
            totalCommandsTimeoutLeft = settings.TotalCommandsTimeout;
            this.internalLogger      = internalLogger;
            this.cancellationToken   = cancellationToken;
            PlayerKey = ThreadLocalRandom.Instance.NextLong();
            PlayerId  = playerId;
            Role      = role;
            Stats     = new ApiPlayerStats
            {
                PlayerKey = PlayerKey,
                Role      = role,
                Status    = ApiPlayerStatus.NotJoined
            };

            join  = new Operation <JoinArg, GameProtocolResult>(cancellationToken);
            start = new Operation <StartArg, GameProtocolResult>(cancellationToken);
            start.TrySetRequestFaulted();
            commands = new Operation <CommandsArg, GameProtocolResult>(cancellationToken);
            commands.TrySetRequestFaulted();
            currentTask = join.WaitForResponseAsync();
        }
示例#2
0
 public ApiResponsePoller(PlanetWarsServerSettings pwsSettings,
                          IHostApplicationLifetime applicationLifetime)
 {
     this.pwsSettings  = pwsSettings;
     hostShutdownToken = applicationLifetime.ApplicationStopping;
 }
示例#3
0
 public CountdownHandler(PlanetWarsServerSettings pwsSettings)
 {
     this.pwsSettings = pwsSettings;
 }