Example #1
0
        internal RequestProcessor(ref string uriRequest, ref Socket clientSocket)
        {
            IServiceManager serviceManager = ServiceManager.GetInstance();

            logger             = serviceManager.GetService <ILoggingService>();
            controllerManager  = serviceManager.GetService <IControllerManager>();
            interceptorManager = serviceManager.GetService <IInterceptorManagerService>();
            telemetry          = serviceManager.GetService <ITelemetryDataCollector>();

            typedObjManager   = new TypedObjectsRequestManager();
            this.clientSocket = clientSocket;
            try
            {
                using (StringReader sr = new StringReader(uriRequest))
                {
                    using (JsonReader reader = new JsonTextReader(sr))
                    {
                        JsonSerializer ser = new JsonSerializer();
                        ser.ApplyCustomSettings();
                        requestBody = ser.Deserialize <RequestBody>(reader);
                    }
                }

                this.clientSocket = clientSocket;
                if (requestBody == null)
                {
                    return;
                }

                uriRequest = null;
            }
            catch (Exception ex)
            {
                string msg = ex.Message;
                if (ex.InnerException != null)
                {
                    msg += ex.InnerException.Message;
                    if (ex.InnerException.InnerException != null)
                    {
                        msg += ex.InnerException.InnerException.Message;
                    }
                }

                logger.WriteLog($@"A syntax error was detected while converting the request body to a server object. 
{msg}", ServerLogType.ERROR);
                new SocketRequest().ProcessResponse(ActionResult.Json("", ResponseStatus.ERROR,
                                                                      $@"A syntax error was detected while converting the request body to a server object. 
{msg}"), this.clientSocket, null);
            }
        }
        public override void OnPostExecute(object result)
        {
            clientSocket       = null;
            typedObjManager    = null;
            requestBody        = null;
            method             = null;
            logger             = null;
            controllerManager  = null;
            interceptorManager = null;
            telemetry          = null;
            controller         = null;


            DownThreadCount();
        }