Ejemplo n.º 1
0
        public Task <ServerResponse> RouteAsync(string userId, ClientRequest clientRequest)
        {
            if (string.IsNullOrEmpty(clientRequest?.RequestName))
            {
                throw new ArgumentException($"Route was empty. ClientId {userId}");
            }

            if (!clientRequest.RequestName.Contains("Action."))
            {
                _logger.Warn($"Request name '{clientRequest.RequestName}' does not follow correct naming and will be ignored");
                return(Task.FromResult(new ServerResponse(ResponseType.RequestMalformed, "Request expected to prefix '.Action'")));
            }

            try
            {
                _actionInserter.Insert(userId, clientRequest.RequestName, clientRequest.Payload);
                return(Task.FromResult(new ServerResponse(ResponseType.RequestAccepted, clientRequest.RequestName)));
            }
            catch (Exception e)
            {
                _logger.Error(e);
            }

            return(Task.FromResult(new ServerResponse(ResponseType.RequestDeclined, "Action not processed")));
        }
Ejemplo n.º 2
0
        private void PerformAttack()
        {
            var attack = new AttackAction(_self.Id, _targetId);

            _actionInserter.Insert(attack);
        }