Exemplo n.º 1
0
        public async Task <Response> SendAsync(Request req)
        {
            s_diagnosticListener.ClientRequest(req);
            Response response = null;

            try
            {
                req.RequestId = callBack.NewCallBackId();
                await SendRequestAsync(req);

                if (req.IsOneway)
                {
                    response = req.CreateResponse();
                }
                else
                {
                    response = await callBack.NewCallBackTask(req.RequestId, req.Timeout, req.ServantName, req.FuncName);

                    response.CheckResultStatus();
                    response.Codec = req.Codec;
                }

                return(response);
            }
            catch (Exception ex)
            {
                s_diagnosticListener.ClientException(req, response, ex);
                throw;
            }
            finally
            {
                s_diagnosticListener.ClientResponse(req, response);
            }
        }
Exemplo n.º 2
0
        public void WhenCanClientExceptionShouldSameRequest()
        {
            var listener = new DiagnosticListener(D.DiagnosticListenerName);
            var sut      = new TestDiagnostic();

            listener.SubscribeWithAdapter(sut);
            var result   = new Request();
            var response = new Response();
            var ex       = new Exception();

            listener.ClientException(result, response, ex);
            Assert.Same(result, sut.Request);
            Assert.Same(response, sut.Response);
            Assert.Same(ex, sut.Exception);
        }
Exemplo n.º 3
0
 public override void ExceptionCaught(IChannelHandlerContext context, Exception ex)
 {
     _client.RaiseError(new SocketContext <TMessage>(context.Channel), ex);
     listener.ClientException(ex);
     context.CloseAsync(); //关闭连接
 }