예제 #1
0
        /// <summary>
        ///     Notify bot that it's been consumed.
        /// </summary>
        /// <param name="botId"></param>
        /// <returns></returns>
        public async Task PlayerConsumed(Guid botId)
        {
            if (runnerStateService.GetEngine().ConnectionId != Context.ConnectionId)
            {
                await SendGameException(
                    new GameException
                {
                    ExceptionMessage = $"Invalid engine connection, botId {botId} not notified on consumed status."
                });

                return;
            }

            var botConnectionId = runnerStateService.GetActiveConnections().FirstOrDefault(c => c.Key == botId).Value;

            runnerStateService.DeregisterBot(botConnectionId);
            Logger.LogInfo("PlayerConsumed", $"Notifying botId {botId} of consumed status.");

            if (!string.IsNullOrWhiteSpace(botConnectionId))
            {
                await Clients.Client(botConnectionId).SendAsync("ReceivePlayerConsumed");

                await Clients.Client(botConnectionId).SendAsync("Disconnect", botId);
            }
        }
예제 #2
0
        private void ComponentsConnectionTimeout(object sender, ElapsedEventArgs e)
        {
            var componentTimedOut = false;
            var components        = new List <string>();

            if (runnerStateService.GetEngine() == default)
            {
                components.Add("GameEngine");
                componentTimedOut = true;
            }

            if (runnerStateService.GetLogger() == default)
            {
                components.Add("Logger");
                componentTimedOut = true;
            }

            if (componentTimedOut)
            {
                var failReason = $"The following components did not connect before timeout: {string.Join(", ", components.ToArray())}";
                Logger.LogDebug(
                    "RunnerHub.OnComponentTimeout",
                    failReason);
                runnerStateService.FailureReason = failReason;
                cloudIntegrationService.Announce(CloudCallbackType.Failed)
                .GetAwaiter()
                .OnCompleted(() => runnerStateService.StopApplication());
            }
        }
예제 #3
0
        public IActionResult GetEngineHealth()
        {
            var engine = runnerStateService.GetEngine();

            if (engine != null)
            {
                return(Ok("Engine is available"));
            }

            return(new StatusCodeResult(StatusCodes.Status503ServiceUnavailable));
        }