Exemple #1
0
        public Task <IntMessage> Sub(SubRequest request, ServerCallContext context)
        {
            var result = new IntMessage();

            result.Value = request.Num1 - request.Num2;
            return(Task.FromResult(result));
        }
Exemple #2
0
        /// <summary>
        /// 服务端流求和
        /// </summary>
        /// <param name="request"></param>
        /// <param name="responseStream"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task SumServerStream(SumRequest request, IServerStreamWriter <IntMessage> responseStream, ServerCallContext context)
        {
            var result = new IntMessage();

            result.Value = request.Num;
            await responseStream.WriteAsync(result);
        }
Exemple #3
0
        public async Task <IntMessage> Sum(IAsyncStreamReader <SumRequest> request, ServerCallContext context)
        {
            var result = new IntMessage();
            int sum    = 0;
            await request.ForEachAsync(req =>
            {
                sum += req.Num;
                return(Task.CompletedTask);
            });

            result.Value = sum;
            return(result);
        }