Пример #1
0
        /// <summary>
        /// Enables processing of HTTP Web requests by a custom HttpHandler that implements the <see cref="T:System.Web.IHttpHandler"/> interface.
        /// </summary>
        /// <param name="context">An <see cref="T:System.Web.HttpContext"/> object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.</param>
        public void ProcessRequest(HttpContext context)
        {
            PollingResult result;

            try
            {
                var session = GetSession(context);
                result = session.HandlePollingRequest(context);
            }
            catch (Exception ex)
            {
                //Application should handle the request and give a valid result.
                //Any exception is a sign that session is not valid anymore.
                result = new PollingResult
                {
                    type    = "rpc",
                    name    = "message",
                    success = false,
                    data    = new DextopRemoteMethodCallException
                    {
                        exception = ex.Message,
                        type      = "session"
                    }
                };
            }

            context.Response.ContentType = "application/json";
            DextopUtil.Encode(result, context.Response.Output);
        }
Пример #2
0
		/// <summary>
		/// Enables processing of HTTP Web requests by a custom HttpHandler that implements the <see cref="T:System.Web.IHttpHandler"/> interface.
		/// </summary>
		/// <param name="context">An <see cref="T:System.Web.HttpContext"/> object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.</param>
        public void ProcessRequest(HttpContext context)
        {
            PollingResult result;
            try
            {
                var session = GetSession(context);
                result = session.HandlePollingRequest(context);
            }
            catch (Exception ex)
            {
                //Application should handle the request and give a valid result.
                //Any exception is a sign that session is not valid anymore.
                result = new PollingResult
                {
                    type = "rpc",
                    name = "message",
                    success = false,
                    data = new DextopRemoteMethodCallException
                    {
                        exception = ex.Message,
                        type = "session"
                    }
                };
            }

            context.Response.ContentType = "application/json";
            DextopUtil.Encode(result, context.Response.Output);
        }
 internal PollingResult HandlePollingRequest(HttpContext context)
 {
     var result = new PollingResult
     {
         type = "rpc",
         name = "message"
     };
     try
     {
         int nextStart;
         var msgs = PopMessages(null, out nextStart);
         result.success = true;
         result.data = msgs;
     }
     catch (Exception ex)
     {
         result.data = new DextopRemoteMethodCallException
         {
             type = "message",
             exception = ex.Message,
             stackTrace = ex.StackTrace
         };
     }
     return result;
 }