1 #region Copyright notice and license 2 3 // Copyright 2015 gRPC authors. 4 // 5 // Licensed under the Apache License, Version 2.0 (the "License"); 6 // you may not use this file except in compliance with the License. 7 // You may obtain a copy of the License at 8 // 9 // http://www.apache.org/licenses/LICENSE-2.0 10 // 11 // Unless required by applicable law or agreed to in writing, software 12 // distributed under the License is distributed on an "AS IS" BASIS, 13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 // See the License for the specific language governing permissions and 15 // limitations under the License. 16 17 #endregion 18 19 using System; 20 using System.Threading; 21 using System.Threading.Tasks; 22 using Grpc.Core; 23 24 namespace Grpc.Core.Internal 25 { 26 internal static class ServerCalls 27 { 28 public static IServerCallHandler UnaryCall<TRequest, TResponse>(Method<TRequest, TResponse> method, UnaryServerMethod<TRequest, TResponse> handler) 29 where TRequest : class 30 where TResponse : class 31 { 32 return new UnaryServerCallHandler<TRequest, TResponse>(method, handler); 33 } 34 35 public static IServerCallHandler ClientStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, ClientStreamingServerMethod<TRequest, TResponse> handler) 36 where TRequest : class 37 where TResponse : class 38 { 39 return new ClientStreamingServerCallHandler<TRequest, TResponse>(method, handler); 40 } 41 42 public static IServerCallHandler ServerStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, ServerStreamingServerMethod<TRequest, TResponse> handler) 43 where TRequest : class 44 where TResponse : class 45 { 46 return new ServerStreamingServerCallHandler<TRequest, TResponse>(method, handler); 47 } 48 49 public static IServerCallHandler DuplexStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, DuplexStreamingServerMethod<TRequest, TResponse> handler) 50 where TRequest : class 51 where TResponse : class 52 { 53 return new DuplexStreamingServerCallHandler<TRequest, TResponse>(method, handler); 54 } 55 } 56 } 57