예제 #1
0
 public IMessageLite CallMethod(string method, ICodedInputStream input, ExtensionRegistry registry)
 {
     if (method == ".multi")
     {
         return(MultiPartMessage(RpcMultiPartRequest.ParseFrom(input, registry), registry));
     }
     else
     {
         return(next.CallMethod(method, input, registry));
     }
 }
예제 #2
0
 public IMessageLite CallMethod(string methodName, ICodedInputStream input, ExtensionRegistry registry)
 {
     using (RpcCallContext.Current.Impersonate())
     {
         return(_stub.CallMethod(methodName, input, registry));
     }
 }
            byte[] IWireTransfer.Execute(string method, byte[] message)
            {
                //now when we recieve a wire transmission to invoke a method by name with a byte[] or stream payload
                //we just simply call the sub:
                IMessageLite response = _stub.CallMethod(method, CodedInputStream.CreateInstance(message),
                                                         ExtensionRegistry.Empty);

                //now we return the expected response message:
                return(response.ToByteArray());
            }
예제 #4
0
        public virtual Stream Invoke(Stream request)
        {
            ICodedInputStream input  = CodedInputStream.CreateInstance(request);
            string            method = null;

            input.ReadString(ref method);
            IMessageLite response = _createStub.CallMethod(method, input, ExtensionRegistry.Empty);

            return(new MemoryStream(response.ToByteArray()));
        }
예제 #5
0
        /// <summary>
        /// Used to implement a service endpoint on an HTTP server.  This works with services generated with the
        /// service_generator_type option set to IRPCDISPATCH.
        /// </summary>
        /// <param name="stub">The service execution stub</param>
        /// <param name="methodName">The name of the method being invoked</param>
        /// <param name="options">optional arguments for the format reader/writer</param>
        /// <param name="contentType">The mime type for the input stream</param>
        /// <param name="input">The input stream</param>
        /// <param name="responseType">The mime type for the output stream</param>
        /// <param name="output">The output stream</param>
        public static void HttpCallMethod(
#if !NOEXTENSIONS
            this
#endif
            IRpcServerStub stub, string methodName, MessageFormatOptions options,
            string contentType, Stream input, string responseType, Stream output)
        {
            ICodedInputStream codedInput = MessageFormatFactory.CreateInputStream(options, contentType, input);

            codedInput.ReadMessageStart();
            IMessageLite response = stub.CallMethod(methodName, codedInput, options.ExtensionRegistry);

            codedInput.ReadMessageEnd();
            WriteTo(response, options, responseType, output);
        }
 public virtual IMessageLite CallMethod(RpcRequestHeader requestHeader, CodedInputStream input)
 {
     if (requestHeader.MethodName == ".close")
     {
         Close();
         return(RpcVoid.DefaultInstance);
     }
     else if (requestHeader.MethodName == ".ping")
     {
         return(OnPing(RpcPingRequest.ParseFrom(input, ExtensionRegistry)));
     }
     else
     {
         return(_implementation.CallMethod(requestHeader.MethodName, input, ExtensionRegistry));
     }
 }