/// <inheritdoc/>
        public override async Task <IServiceRemotingResponseMessage> HandleRequestResponseAsync(IServiceRemotingRequestContext requestContext,
                                                                                                IServiceRemotingRequestMessage requestMessage)
        {
            var handleExtended = false;
            Uri serviceUri     = null;

            object    state     = null;
            Exception exception = null;

            var header = requestMessage.GetHeader() as IActorRemotingMessageHeaders;

            //check to see if message headers are assignable
            if (header != null)
            {
                handleExtended = true;
                serviceUri     = (Uri)header.GetCustomHeaders()[CustomHeaders.ReservedHeaderServiceUri];
                RemotingContext.FromRemotingMessageHeader(header);
            }

            if (BeforeHandleRequestResponseAsync != null && handleExtended)
            {
                state = await BeforeHandleRequestResponseAsync.Invoke(new ActorRequestInfo(requestMessage, header.ActorId, header.MethodName, serviceUri));
            }

            IServiceRemotingResponseMessage responseMessage = null;

            try
            {
                responseMessage = await base.HandleRequestResponseAsync(requestContext, requestMessage);
            }
            catch (Exception ex)
            {
                exception = ex;
                throw;
            }
            finally
            {
                if (AfterHandleRequestResponseAsync != null && handleExtended)
                {
                    await AfterHandleRequestResponseAsync.Invoke(new ActorResponseInfo(responseMessage, header.ActorId, header.MethodName, serviceUri, state, exception));
                }
            }

            return(responseMessage);
        }
        /// <inheritdoc/>
        public override async Task <IServiceRemotingResponseMessage> HandleRequestResponseAsync(IServiceRemotingRequestContext requestContext,
                                                                                                IServiceRemotingRequestMessage requestMessage)
        {
            var header = requestMessage.GetHeader();

            var serviceUri = (Uri)header.GetCustomHeaders()[CustomHeaders.ReservedHeaderServiceUri];

            RemotingContext.FromRemotingMessageHeader(header);

            object    state     = null;
            Exception exception = null;

            if (BeforeHandleRequestResponseAsync != null)
            {
                state = await BeforeHandleRequestResponseAsync.Invoke(new ServiceRequestInfo(requestMessage, header.MethodName, serviceUri));
            }

            IServiceRemotingResponseMessage responseMessage = null;

            try
            {
                responseMessage = await base.HandleRequestResponseAsync(requestContext, requestMessage);
            }
            catch (Exception ex)
            {
                exception = ex;
                throw;
            }
            finally
            {
                if (AfterHandleRequestResponseAsync != null)
                {
                    await AfterHandleRequestResponseAsync.Invoke(new ServiceResponseInfo(responseMessage, header.MethodName, serviceUri, state, exception));
                }
            }

            return(responseMessage);
        }
 /// <inheritdoc/>
 public override void HandleOneWayMessage(IServiceRemotingRequestMessage requestMessage)
 {
     RemotingContext.FromRemotingMessageHeader(requestMessage.GetHeader());
     base.HandleOneWayMessage(requestMessage);
 }