/// <summary> /// Creates a new instance of <c>ServerCallContext</c>. /// To allow reuse of ServerCallContext API by different gRPC implementations, the implementation of some members is provided externally. /// To provide state, this <c>ServerCallContext</c> instance and <c>extraData</c> will be passed to the member implementations. /// </summary> internal DefaultServerCallContext(CallSafeHandle callHandle, string method, string host, DateTime deadline, Metadata requestHeaders, CancellationToken cancellationToken, IServerResponseStream serverResponseStream) { this.callHandle = callHandle; this.method = method; this.host = host; this.deadline = deadline; this.requestHeaders = requestHeaders; this.cancellationToken = cancellationToken; this.responseTrailers = new Metadata(); this.status = Status.DefaultSuccess; this.serverResponseStream = serverResponseStream; }
/// <summary> /// Creates a new instance of <c>ServerCallContext</c>. /// To allow reuse of ServerCallContext API by different gRPC implementations, the implementation of some members is provided externally. /// To provide state, this <c>ServerCallContext</c> instance and <c>extraData</c> will be passed to the member implementations. /// </summary> internal DefaultServerCallContext(CallSafeHandle callHandle, string method, string host, DateTime deadline, Metadata requestHeaders, CancellationToken cancellationToken, IServerResponseStream serverResponseStream) { this.callHandle = callHandle; this.method = method; this.host = host; this.deadline = deadline; this.requestHeaders = requestHeaders; this.cancellationToken = cancellationToken; this.responseTrailers = new Metadata(); this.status = Status.DefaultSuccess; this.serverResponseStream = serverResponseStream; // TODO(jtattermusch): avoid unnecessary allocation of factory function and the lazy object this.authContext = new Lazy <AuthContext>(GetAuthContextEager); }
public static ServerCallContext NewContext(ServerRpcNew newRpc, IServerResponseStream serverResponseStream, CancellationToken cancellationToken) { DateTime realtimeDeadline = newRpc.Deadline.ToClockType(ClockType.Realtime).ToDateTime(); return(new DefaultServerCallContext(newRpc.Call, newRpc.Method, newRpc.Host, realtimeDeadline, newRpc.RequestMetadata, cancellationToken, serverResponseStream)); }