Exemple #1
0
        public Task RouteCall(HttpContext context, string path)
        {
            var pathAction         = PathActionParser.GetPathAction(path);
            var messageHandlerName = GetNextPathParameter(path, pathAction.Path.Length);

            if (pathAction.PathAction == PathAction.WebSocketConnect)
            {
                return(this.ConnectWebSocketRequestValidation(context, messageHandlerName, GetPathRequestInformation(path, pathAction, messageHandlerName)));
            }

            var pipeline = new HttpContextResponseOutputMessagePipeline(context);

            switch (pathAction.PathAction)
            {
            case PathAction.SendMessage:
                return(this.SendMessageAsync(context, path, messageHandlerName, pathAction));

            case PathAction.ReceiveMessage:
                return(this.ProcessGet(messageHandlerName, pipeline));

            case PathAction.ReceiveMessageWait:
                return(this.ProcessGetAwait(messageHandlerName, new ContextIsClientConnected(context), pipeline));

            case PathAction.SendAndReceiveMessageWait:
                return(this.SendAndReceiveMessageWaitAsync(context, path, messageHandlerName, pipeline, pathAction));

            case PathAction.CreateQueue:
                return(this.CreateQueue(messageHandlerName));

            case PathAction.CreateApplication:
                return(this.CreateApplication(messageHandlerName));

            case PathAction.CreateBus:
                return(this.CreateBus(messageHandlerName));
            }

            return(RouteFailedTask);
        }
Exemple #2
0
        private Task SendAndReceiveMessageWaitAsync(HttpContext context, string path, string messageHandlerName, HttpContextResponseOutputMessagePipeline pipeline, PathActionMapItem pathAction)
        {
            {
                var method = context.Request.Method;
                var isPost = string.CompareOrdinal("POST", method) == 0;

                return(isPost
                           ? this.SendAndReceiveMessageWait(messageHandlerName, context.Request.Body, new ContextIsClientConnected(context), pipeline)
                           : this.SendAndReceiveMessageWait(messageHandlerName, GetPathRequestInformation(path, pathAction, messageHandlerName), new ContextIsClientConnected(context), pipeline));
            }
        }