コード例 #1
0
ファイル: AMFGateway.cs プロジェクト: saggelopoulos/AMFCore
        /// <summary>
        /// Occurs just before ASP.NET begins executing a handler such as a page or XML Web service.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        public async Task PreRequest(object context)
        {
            if (DependencyInjection.HttpContextManager.HttpContext.GetContentType() == ContentType.AMF)
            {
                DependencyInjection.HttpContextManager.HttpContext.Clear(context);
                DependencyInjection.HttpContextManager.HttpContext.SetContentType(ContentType.AMF);

                try
                {
                    AMFWebContext.Initialize();

                    if (messageServer != null)
                    {
                        await messageServer.Service();
                    }

                    DependencyInjection.HttpContextManager.HttpContext.Finish(context);
                }
                catch (Exception)
                {
                    DependencyInjection.HttpContextManager.HttpContext.Clear(context);
                    DependencyInjection.HttpContextManager.HttpContext.Finish(context);
                }
            }
        }
コード例 #2
0
 internal void HandleXAmfEx(HttpApplication httpApplication)
 {
     if (httpApplication.Request.ContentType == "application/x-amf")
     {
         this.CompressContent(httpApplication);
         httpApplication.Response.Clear();
         httpApplication.Response.ContentType = "application/x-amf";
         ILog logger = null;
         try
         {
             logger = LogManager.GetLogger(typeof(FluorineGateway));
             GlobalContext.get_Properties().set_Item("ClientIP", HttpContext.Current.Request.UserHostAddress);
         }
         catch
         {
         }
         if ((logger != null) && logger.get_IsDebugEnabled())
         {
             logger.Debug(__Res.GetString("Amf_Begin"));
         }
         try
         {
             FluorineWebContext.Initialize();
             if (messageServer != null)
             {
                 messageServer.Service();
             }
             else if (logger != null)
             {
                 logger.Fatal(__Res.GetString("MessageServer_AccessFail"));
             }
             if ((logger != null) && logger.get_IsDebugEnabled())
             {
                 logger.Debug(__Res.GetString("Amf_End"));
             }
             httpApplication.CompleteRequest();
         }
         catch (Exception exception)
         {
             if (logger != null)
             {
                 logger.Fatal(__Res.GetString("Amf_Fatal"), exception);
             }
             httpApplication.Response.Clear();
             httpApplication.Response.ClearHeaders();
             httpApplication.Response.Status = __Res.GetString("Amf_Fatal404") + " " + exception.Message;
             httpApplication.CompleteRequest();
         }
     }
 }