Example #1
0
        public bool ProcessRequest(HTTPSourcedRequest externalRequest)
        {
            MicroServices.RequestType rType;
            bool ableToParseRequest = MicroServices.ParseRequestType(externalRequest.RequestType, out rType);

            // Handle Command
            if (ableToParseRequest)
            {
                Logger.Debug($"HTTP Client Bridge Converted Request'{externalRequest.RequestType}' to internal value '{rType.ToString()}'.");
                TrackConnection(externalRequest);

                switch (rType)
                {
                case MicroServices.RequestType.GetList:
                {
                    TranslateExternalGetListRequestToAkkaMessage(externalRequest);
                    break;
                }

                default:
                {
                    throw new NotImplementedException($"This request type has not been implemented:{rType.ToString()}");
                }
                }
            }
            else
            {
                Logger.Debug($"HTTP Client Bridge received unknown request value'{externalRequest.RequestType}'.");
                HTTPExternalInterface.HandleFailedStateMessage(new HTTPDestinedRequestStateEvent(MicroServices.ProcessingStatus.Failed, "Unknown request:" + externalRequest.RequestType, externalRequest), true);
            }

            return(ableToParseRequest);
        }
Example #2
0
        public bool TranslateAkkaGetListResponseToExternalMessage(Response akkaResponse)
        {
            UserGetListResponse response    = akkaResponse as UserGetListResponse;
            UserGetListRequest  request     = response.OriginalRequest as UserGetListRequest;
            HTTPSourcedRequest  httpRequest = request.OriginalHTTPRequest;


            HTTPExternalInterface.HandleRequestResponse(new HTTPDestinedRequestResponse(MicroServices.ProcessingStatus.Processed, response.ListOfUserStates, httpRequest), false);
            return(true);
        }
Example #3
0
        /// <summary>
        /// This external request message handler parses the JSON message and attempts to determine the area to which it belongs.
        /// Once it has done that it will forward the message to the actor responsible for handling the discovered area.
        /// </summary>
        /// <param name="r"></param>
        private void ProcessExternalHTTPRequestHandler(HTTPSourcedRequest r)
        {
            MicroServices.RequestType rType;
            MicroServices.Area        area;
            bool ableToParseRequest = MicroServices.ParseRequestType(r.RequestType, out rType);
            bool ableToParseArea    = MicroServices.ParseArea(r.Area, out area);

            // Handle Area
            if (ableToParseArea)
            {
                _logger.Debug("HTTP Client Bridge Converted Area'{0}' to internal value{1}.", r.Area, area.ToString());
                _logger.Debug("Adding user '{0}' to group '{1}'", r.User, area.ToString());

                TrackConnection(r, area);

                // Now that we know the area we can forward it to the Area request handler
                Context.Child($"{area}{_IncomingMessageProcessorName}").Tell(r);
            }
            else
            {
                _logger.Debug("HTTP Client Bridge received unknown string area value'{0}'.", r.Area);
                _HTTPClientInterface.HandleFailedStateMessage(new HTTPDestinedRequestStateEvent(MicroServices.ProcessingStatus.Failed, "Unknown area:" + r.Area, r), true);
            }
        }
        // - Actions are abstract
        // - Commands is a kind of Action
        // - Requests is a kind of Action

        public HTTPDestinedRequestResponse(MicroServices.ProcessingStatus status, object responseData, HTTPSourcedRequest originalAction)
        {
            ConnectionId = originalAction.ConnectionId;
            Action       = originalAction.RequestType;
            User         = originalAction.User;
            Area         = originalAction.Area;
            Status       = status.ToString();
            Data         = responseData;
        }
        // - Actions are abstract
        // - Commands is a kind of Action
        // - Requests is a kind of Action


        public HTTPDestinedRequestStateEvent(MicroServices.ProcessingStatus status, string message, HTTPSourcedRequest originalRequest) : base(status, message, originalRequest)
        {
            RequestType = originalRequest.RequestType;
        }
Example #6
0
        public void TranslateExternalGetListRequestToAkkaMessage(HTTPSourcedRequest externalRequest)
        {
            ClientGetListRequest getListRequest = new ClientGetListRequest(ReplyTo, externalRequest);

            SendTo.Tell(getListRequest, ReplyTo);
        }