using System.Collections.Generic;
using System.Text;
using Google.ProtocolBuffers;
using System.IO;
namespace Google.ProtocolBuffers.Serialization
{
///
/// Extensions for the IRpcServerStub
///
public static class ServiceExtensions
{
///
/// Used to implement a service endpoint on an HTTP server. This works with services generated with the
/// service_generator_type option set to IRPCDISPATCH.
///
/// The service execution stub
/// The name of the method being invoked
/// optional arguments for the format reader/writer
/// The mime type for the input stream
/// The input stream
/// The mime type for the output stream
/// The output stream
public static void HttpCallMethod(this IRpcServerStub stub, string methodName, MessageFormatOptions options,
string contentType, Stream input, string responseType, Stream output)
{
ICodedInputStream codedInput = MessageFormatFactory.CreateInputStream(options, contentType, input);
IMessageLite response = stub.CallMethod(methodName, codedInput, options.ExtensionRegistry);
response.WriteTo(options, responseType, output);
}
}
}