diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc index bc40880e5ca39a40c22adbc9481ef7496a6dbf4d..4a96a909def169cdee181f001a9b8f9a20239235 100644 --- a/src/compiler/csharp_generator.cc +++ b/src/compiler/csharp_generator.cc @@ -388,7 +388,7 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor *service) { GetClassName(method->output_type())); out->Print("{\n"); out->Indent(); - out->Print("return CallInvoker.BlockingUnaryCall($methodfield$, options, request);\n", + out->Print("return CallInvoker.BlockingUnaryCall($methodfield$, null, options, request);\n", "methodfield", GetMethodFieldName(method)); out->Outdent(); out->Print("}\n"); @@ -422,20 +422,20 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor *service) { out->Indent(); switch (GetMethodType(method)) { case METHODTYPE_NO_STREAMING: - out->Print("return CallInvoker.AsyncUnaryCall($methodfield$, options, request);\n", + out->Print("return CallInvoker.AsyncUnaryCall($methodfield$, null, options, request);\n", "methodfield", GetMethodFieldName(method)); break; case METHODTYPE_CLIENT_STREAMING: - out->Print("return CallInvoker.AsyncClientStreamingCall($methodfield$, options);\n", + out->Print("return CallInvoker.AsyncClientStreamingCall($methodfield$, null, options);\n", "methodfield", GetMethodFieldName(method)); break; case METHODTYPE_SERVER_STREAMING: out->Print( - "return CallInvoker.AsyncServerStreamingCall($methodfield$, options, request);\n", + "return CallInvoker.AsyncServerStreamingCall($methodfield$, null, options, request);\n", "methodfield", GetMethodFieldName(method)); break; case METHODTYPE_BIDI_STREAMING: - out->Print("return CallInvoker.AsyncDuplexStreamingCall($methodfield$, options);\n", + out->Print("return CallInvoker.AsyncDuplexStreamingCall($methodfield$, null, options);\n", "methodfield", GetMethodFieldName(method)); break; default: diff --git a/src/csharp/Grpc.Core/CallInvoker.cs b/src/csharp/Grpc.Core/CallInvoker.cs index e8e43968f8bf6225894d191cce13b1767ddf3b52..cec5255692da41a6138d5ed2cc9baf350098cfb7 100644 --- a/src/csharp/Grpc.Core/CallInvoker.cs +++ b/src/csharp/Grpc.Core/CallInvoker.cs @@ -45,14 +45,14 @@ namespace Grpc.Core /// <summary> /// Invokes a simple remote call in a blocking fashion. /// </summary> - public abstract TResponse BlockingUnaryCall<TRequest, TResponse>(Method<TRequest, TResponse> method, CallOptions options, TRequest request) + public abstract TResponse BlockingUnaryCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options, TRequest request) where TRequest : class where TResponse : class; /// <summary> /// Invokes a simple remote call asynchronously. /// </summary> - public abstract AsyncUnaryCall<TResponse> AsyncUnaryCall<TRequest, TResponse>(Method<TRequest, TResponse> method, CallOptions options, TRequest request) + public abstract AsyncUnaryCall<TResponse> AsyncUnaryCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options, TRequest request) where TRequest : class where TResponse : class; @@ -60,7 +60,7 @@ namespace Grpc.Core /// Invokes a server streaming call asynchronously. /// In server streaming scenario, client sends on request and server responds with a stream of responses. /// </summary> - public abstract AsyncServerStreamingCall<TResponse> AsyncServerStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, CallOptions options, TRequest request) + public abstract AsyncServerStreamingCall<TResponse> AsyncServerStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options, TRequest request) where TRequest : class where TResponse : class; @@ -68,7 +68,7 @@ namespace Grpc.Core /// Invokes a client streaming call asynchronously. /// In client streaming scenario, client sends a stream of requests and server responds with a single response. /// </summary> - public abstract AsyncClientStreamingCall<TRequest, TResponse> AsyncClientStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, CallOptions options) + public abstract AsyncClientStreamingCall<TRequest, TResponse> AsyncClientStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options) where TRequest : class where TResponse : class; @@ -77,7 +77,7 @@ namespace Grpc.Core /// In duplex streaming scenario, client sends a stream of requests and server responds with a stream of responses. /// The response stream is completely independent and both side can be sending messages at the same time. /// </summary> - public abstract AsyncDuplexStreamingCall<TRequest, TResponse> AsyncDuplexStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, CallOptions options) + public abstract AsyncDuplexStreamingCall<TRequest, TResponse> AsyncDuplexStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options) where TRequest : class where TResponse : class; } diff --git a/src/csharp/Grpc.Core/ClientBase.cs b/src/csharp/Grpc.Core/ClientBase.cs index f5d6ae744f4fc1e769d0129360b2c1537feb948e..9f3c4a53275dcc5da029c61f6061274d079ae52f 100644 --- a/src/csharp/Grpc.Core/ClientBase.cs +++ b/src/csharp/Grpc.Core/ClientBase.cs @@ -124,11 +124,11 @@ namespace Grpc.Core /// By default, this will be set to <c>null</c> with the meaning /// "use default host". /// </summary> - public string Host - { - get; - set; - } + //public string Host + //{ + // get; + // set; + //} /// <summary> /// Creates a new call to given method. diff --git a/src/csharp/Grpc.Core/DefaultCallInvoker.cs b/src/csharp/Grpc.Core/DefaultCallInvoker.cs index 8b77651c0cf3c6c05fd9eb8a485f78313154d10c..5329478a159572968141544ee569d5553d85b932 100644 --- a/src/csharp/Grpc.Core/DefaultCallInvoker.cs +++ b/src/csharp/Grpc.Core/DefaultCallInvoker.cs @@ -56,18 +56,18 @@ namespace Grpc.Core /// <summary> /// Invokes a simple remote call in a blocking fashion. /// </summary> - public override TResponse BlockingUnaryCall<TRequest, TResponse>(Method<TRequest, TResponse> method, CallOptions options, TRequest request) + public override TResponse BlockingUnaryCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options, TRequest request) { - var call = CreateCall(method, options); + var call = CreateCall(method, host, options); return Calls.BlockingUnaryCall(call, request); } /// <summary> /// Invokes a simple remote call asynchronously. /// </summary> - public override AsyncUnaryCall<TResponse> AsyncUnaryCall<TRequest, TResponse>(Method<TRequest, TResponse> method, CallOptions options, TRequest request) + public override AsyncUnaryCall<TResponse> AsyncUnaryCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options, TRequest request) { - var call = CreateCall(method, options); + var call = CreateCall(method, host, options); return Calls.AsyncUnaryCall(call, request); } @@ -75,9 +75,9 @@ namespace Grpc.Core /// Invokes a server streaming call asynchronously. /// In server streaming scenario, client sends on request and server responds with a stream of responses. /// </summary> - public override AsyncServerStreamingCall<TResponse> AsyncServerStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, CallOptions options, TRequest request) + public override AsyncServerStreamingCall<TResponse> AsyncServerStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options, TRequest request) { - var call = CreateCall(method, options); + var call = CreateCall(method, host, options); return Calls.AsyncServerStreamingCall(call, request); } @@ -85,9 +85,9 @@ namespace Grpc.Core /// Invokes a client streaming call asynchronously. /// In client streaming scenario, client sends a stream of requests and server responds with a single response. /// </summary> - public override AsyncClientStreamingCall<TRequest, TResponse> AsyncClientStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, CallOptions options) + public override AsyncClientStreamingCall<TRequest, TResponse> AsyncClientStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options) { - var call = CreateCall(method, options); + var call = CreateCall(method, host, options); return Calls.AsyncClientStreamingCall(call); } @@ -96,22 +96,17 @@ namespace Grpc.Core /// In duplex streaming scenario, client sends a stream of requests and server responds with a stream of responses. /// The response stream is completely independent and both side can be sending messages at the same time. /// </summary> - public override AsyncDuplexStreamingCall<TRequest, TResponse> AsyncDuplexStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, CallOptions options) + public override AsyncDuplexStreamingCall<TRequest, TResponse> AsyncDuplexStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options) { - var call = CreateCall(method, options); + var call = CreateCall(method, host, options); return Calls.AsyncDuplexStreamingCall(call); } - protected virtual string Host - { - get { return null; } - } - - protected virtual CallInvocationDetails<TRequest, TResponse> CreateCall<TRequest, TResponse>(Method<TRequest, TResponse> method, CallOptions options) + protected virtual CallInvocationDetails<TRequest, TResponse> CreateCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options) where TRequest : class where TResponse : class { - return new CallInvocationDetails<TRequest, TResponse>(channel, method, Host, options); + return new CallInvocationDetails<TRequest, TResponse>(channel, method, host, options); } } }