ClearCanvas.ImageServer.Services.Streaming.ImageStreaming.WADORequestProcessor.HandleRequest C# (CSharp) Method

HandleRequest() private static method

private static HandleRequest ( HttpListenerContext context ) : void
context System.Net.HttpListenerContext
return void
        private static void HandleRequest(HttpListenerContext context)
        {
            WADORequestProcessorStatistics statistics;
        	
			if (Platform.IsLogLevelEnabled(LogLevel.Debug))
			{
                statistics = new WADORequestProcessorStatistics("Image Streaming");
                statistics.TotalProcessTime.Start();
				//Don't hold up this thread for logging.
				Task.Factory.StartNew(() => LogRequest(context));
			}
            else
            {
                statistics = null;
            }
            
			try
            {
                using (WADORequestTypeHandlerManager handlerManager = new WADORequestTypeHandlerManager())
                {
                    string requestType = context.Request.QueryString["requestType"];
                    IWADORequestTypeHandler typeHandler = handlerManager.GetHandler(requestType);

                    WADORequestTypeHandlerContext ctx = new WADORequestTypeHandlerContext
                    {
                        HttpContext = context,
                        ServerAE = UriHelper.GetServerAE(context)
                    };

                    using (WADOResponse response = typeHandler.Process(ctx))
                    {
                        if (response != null)
                        {
                            if (statistics != null)
                            statistics.TransmissionSpeed.Start();
                            
                            SendWADOResponse(response, context);
                            
                            if (statistics != null)
                            statistics.TransmissionSpeed.End();

                            if (statistics != null && response.Output != null)
                                statistics.TransmissionSpeed.SetData(response.Output.Length);
                            }
                        }

                }
            }
            catch(MimeTypeProcessorError error)
            {
                SendError(error.HttpError, context);
            }

            if (statistics != null)
            statistics.TotalProcessTime.End();

			//Seems like something you'd only want to log if there was a problem.
			if (Platform.IsLogLevelEnabled(LogLevel.Debug))
			{
				//Don't hold up this thread for logging.
				Task.Factory.StartNew(() => StatisticsLogger.Log(LogLevel.Debug, statistics));
			}
        }