protected override void AddEventHandlerDefinition <TEventArgs>( RpcEventInfo eventInfo, Func <RpcObjectRequest, IServiceProvider?, IRpcAsyncStreamWriter <TEventArgs>, IRpcContext, ValueTask> beginEventProducer, RpcStub <TService> serviceStub, IGrpcMethodBinder binder) { GrpcCore.ServerStreamingServerMethod <RpcObjectRequest, TEventArgs> handler = (request, responseStream, context) => { using (var scope = CreateServiceScope(serviceStub)) { return(beginEventProducer(request, scope?.ServiceProvider, new GrpcAsyncStreamWriter <TEventArgs>(responseStream), new GrpcCallContext(context)).AsTask()); } }; var beginEventProducerName = $"Begin{eventInfo.Name}"; binder.AddMethod( GrpcMethodDefinition.Create <RpcObjectRequest, TEventArgs>( GrpcCore.MethodType.ServerStreaming, eventInfo.FullServiceName, beginEventProducerName, serviceStub.Serializer), handler); }
protected override void AddCallbackMethodCore <TRequest, TReturn, TResponseReturn>( Func <TService, TRequest, Action <TReturn>, CancellationToken, Task> serviceCaller, Func <TReturn, TResponseReturn>?responseConverter, RpcServerFaultHandler faultHandler, RpcStub <TService> serviceStub, RpcOperationInfo operationInfo, IGrpcMethodBinder binder) where TResponseReturn : class { var serializer = serviceStub.Serializer; GrpcCore.ServerStreamingServerMethod <TRequest, TResponseReturn> handler = (request, responseStream, context) => { using (var serviceScope = CreateServiceScope(serviceStub)) { return(serviceStub.CallCallbackMethod( request, serviceScope?.ServiceProvider, new GrpcCallContext(context), new GrpcAsyncStreamWriter <TResponseReturn>(responseStream), serviceCaller, responseConverter, faultHandler, serializer).AsTask()); } }; binder.AddMethod( GrpcMethodDefinition.Create <TRequest, TResponseReturn>( GrpcCore.MethodType.ServerStreaming, operationInfo.FullServiceName, operationInfo.Name, serviceStub.Serializer), handler); }
public void AddMethod <TRequest, TResponse>(GrpcCore.Method <TRequest, TResponse> method, GrpcCore.ServerStreamingServerMethod <TRequest, TResponse> handler) where TResponse : class where TRequest : class { this.stubs.Add(new TestGrpcMethodStub(method, typeof(TRequest), typeof(TResponse), null)); }
public void AddMethod <TRequest, TResponse>(GrpcCore.Method <TRequest, TResponse> method, GrpcCore.ServerStreamingServerMethod <TRequest, TResponse> handler) where TResponse : class where TRequest : class { this.builder.AddMethod(method, handler); }