public virtual IMessageLite OnExecute(IClientContext client, RpcRequestHeader requestHeader,
                                              CodedInputStream input, RpcResponseHeader.Builder responseHeader)
        {
            RpcCallContext previous = RpcCallContext.g_current;

            try
            {
                responseHeader.SetMessageId(requestHeader.MessageId);
                requestHeader.CallContext.Client = client;
                RpcCallContext.g_current         = requestHeader.CallContext;

                IMessageLite responseBody = CallMethod(requestHeader, input);

                if (RpcCallContext.g_current != null && !requestHeader.CallContext.Equals(RpcCallContext.g_current))
                {
                    responseHeader.SetCallContext(RpcCallContext.g_current);
                }

                return(responseBody);
            }
            catch (Exception ex)
            {
                OnException(requestHeader, responseHeader, ex);
                return(RpcVoid.DefaultInstance);
            }
            finally
            {
                RpcCallContext.g_current = previous;
            }
        }
        protected virtual void OnExecute(IClientContext client, Stream input, Stream output)
        {
            RpcRequestHeader requestHeader = RpcRequestHeader.DefaultInstance;

            RpcResponseHeader.Builder responseHeader = RpcResponseHeader.CreateBuilder();
            try
            {
                requestHeader = RpcRequestHeader.ParseDelimitedFrom(input, ExtensionRegistry);
                responseHeader.SetMessageId(requestHeader.MessageId);

                IMessageLite responseBody = OnExecute(client, requestHeader, CodedInputStream.CreateInstance(input),
                                                      responseHeader);

                responseHeader.Build().WriteDelimitedTo(output);
                responseBody.WriteTo(output);
            }
            catch (Exception ex)
            {
                OnException(requestHeader, responseHeader, ex);
                responseHeader.Build().WriteDelimitedTo(output);
            }
        }