Exemplo n.º 1
0
        public override void PostMethodCall(IApiMethodCall method, ASC.Api.Impl.ApiContext context, object methodResponce)
        {
            var pubSub = ServiceLocator.Current.GetInstance <IApiPubSub>();

            if (pubSub != null)
            {
                pubSub.PublishDataForKey(
                    method.RoutingPollUrl + ":" +
                    PubSubKeyHelper.GetKeyForRoute(context.RequestContext.RouteData.Route.GetRouteData(context.RequestContext.HttpContext)),
                    new ApiMethodCallData()
                {
                    Method = method, Result = methodResponce
                });
            }
            base.PostMethodCall(method, context, methodResponce);
        }
Exemplo n.º 2
0
        public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData)
        {
            var url = ((Route)RouteContext.RouteData.Route).Url;
            //Trim extension
            int extensionDot;

            if ((extensionDot = url.LastIndexOf('.', url.Length - 5)) != -1)
            {
                url = url.Substring(0, extensionDot);
            }

            _key = url + ":" +
                   PubSubKeyHelper.GetKeyForRoute(RouteContext.RouteData.Route.GetRouteData(RouteContext.HttpContext));

            var reqState = new AsyncWaitRequestState(context, cb, extraData);

            Log.Debug("subscribing to key: {0}", _key);
            PubSub.SubscribeForKey(_key, OnDataRecieved, reqState);

            //TODO: Think how to move it
            //Dispose all pending context shit
            new DisposableHttpContext(context).Dispose();
            return(reqState);
        }