using System; using System.Threading; using System.Threading.Tasks; using System.Collections.Generic; using System.Reactive.Linq; using Google.GRPC.Core; namespace math { /// /// Implementation of math service stub (this is handwritten version of code /// that will normally be generated). /// public class MathServiceClientStub : IMathServiceClient { readonly Channel channel; readonly TimeSpan methodTimeout; public MathServiceClientStub(Channel channel, TimeSpan methodTimeout) { this.channel = channel; this.methodTimeout = methodTimeout; } public DivReply Div(DivArgs args, CancellationToken token = default(CancellationToken)) { var call = new Google.GRPC.Core.Call("/math.Math/Div", Serialize_DivArgs, Deserialize_DivReply, methodTimeout, channel); return Calls.BlockingUnaryCall(call, args, token); } public Task DivAsync(DivArgs args, CancellationToken token = default(CancellationToken)) { var call = new Google.GRPC.Core.Call("/math.Math/Div", Serialize_DivArgs, Deserialize_DivReply, methodTimeout, channel); return Calls.AsyncUnaryCall(call, args, token); } public Task Fib(FibArgs args, IObserver outputs, CancellationToken token = default(CancellationToken)) { var call = new Google.GRPC.Core.Call("/math.Math/Fib", Serialize_FibArgs, Deserialize_Num, methodTimeout, channel); return Calls.AsyncServerStreamingCall(call, args, outputs, token); } public ClientStreamingAsyncResult Sum(CancellationToken token = default(CancellationToken)) { var call = new Google.GRPC.Core.Call("/math.Math/Sum", Serialize_Num, Deserialize_Num, methodTimeout, channel); return Calls.AsyncClientStreamingCall(call, token); } public IObserver DivMany(IObserver outputs, CancellationToken token = default(CancellationToken)) { var call = new Google.GRPC.Core.Call("/math.Math/DivMany", Serialize_DivArgs, Deserialize_DivReply, methodTimeout, channel); return Calls.DuplexStreamingCall(call, outputs, token); } private static byte[] Serialize_DivArgs(DivArgs arg) { return arg.ToByteArray(); } private static byte[] Serialize_FibArgs(FibArgs arg) { return arg.ToByteArray(); } private static byte[] Serialize_Num(Num arg) { return arg.ToByteArray(); } private static DivReply Deserialize_DivReply(byte[] payload) { return DivReply.CreateBuilder().MergeFrom(payload).Build(); } private static Num Deserialize_Num(byte[] payload) { return Num.CreateBuilder().MergeFrom(payload).Build(); } } }