public override string DoInBackGround(string receivedData)
        {
            try
            {
                SocketRequest req = new SocketRequest(basicController, "RunAction", new System.Collections.Generic.List <RequestParameter>(),
                                                      preProcessor.clientSocket);

                Stopwatch s = new Stopwatch();
                s.Start();
                object resultObject = basicController.RunAction(receivedData, req);
                s.Stop();

                string resultString = string.Empty;

                if (resultObject != null)
                {
                    resultString = (resultObject.GetType() == typeof(string)
                        ? resultObject.ToString()
                        : JsonConvert.SerializeObject(resultObject, AppServerConfigurator.SerializerSettings));
                }

                byte[] resultBytes = coreServer.GetConfiguration().ServerEncoding.GetBytes(resultString);
                preProcessor.clientSocket.Send(resultBytes);
            }
            catch (Exception ex)
            {
                preProcessor.clientSocket.Send(encoder.ConvertToByteArray($"Error: {ex.Message}"));
                logger.WriteLog($"Basic Server Module Error: {ex.Message}", ServerLogType.ERROR);
            }

            preProcessor.Dispose();
            return(string.Empty);
        }
示例#2
0
        public override string DoInBackGround(string receivedData)
        {
            try
            {
                Stopwatch s = new Stopwatch();
                s.Start();
                ActionResult result = basicController.RunAction(receivedData);
                s.Stop();

                string resultToJson = JsonConvert.SerializeObject(result, AppServerConfigurator.SerializerSettings);

                byte[] resultBytes = coreServer.GetConfiguration().ServerEncoding.GetBytes(resultToJson);
                preProcessor.clientSocket.Send(resultBytes);
            }
            catch (Exception ex)
            {
                preProcessor.clientSocket.Send(encoder.ConvertToByteArray($"Error: {ex.Message}"));
                logger.WriteLog($"Basic Server Module Error: {ex.Message}", ServerLogType.ERROR);
            }

            preProcessor.Dispose();
            return(string.Empty);
        }