Example #1
0
            void ExecuteMessage(BinaryMessage msg)
            {
                BinaryMessage response = null;
                var           sw       = System.Diagnostics.Stopwatch.StartNew();

                try {
                    if (msg.Name == "FlushMessages")
                    {
                        response = msg.CreateResponse();
                    }
                    else
                    {
                        response = listener.ProcessMessage(msg);
                    }
                } catch (Exception ex) {
                    if (ex is TargetInvocationException)
                    {
                        ex = ((TargetInvocationException)ex).InnerException;
                    }
                    server.LogError(ex);
                    response = msg.CreateErrorResponse(ex.Message, !(ex is RemoteProcessException));
                    Console.WriteLine(ex);
                }
                if (response != null)
                {
                    response.Id             = msg.Id;
                    response.ProcessingTime = sw.ElapsedMilliseconds;
                    server.SendResponse(response);
                }
                else if (!msg.OneWay)
                {
                    server.SendResponse(msg.CreateErrorResponse("Got no response from server", true));
                }
            }