示例#1
0
        public async Task <IActionResult> Get()
        {
            var client  = new MessagingInfo.MessagingInfoClient(channel);
            var request = new MessageInfoModel()
            {
                UserId = 2
            };
            var reply = await client.GetMessageByIdAsync(request);

            return(Ok(reply));
            //return await Task.FromResult(Ok("Welcome to GRPC client"));
        }
示例#2
0
        public async IAsyncEnumerable <MessageModel> GetMessagesAsync()
        {
            var client = new MessagingInfo.MessagingInfoClient(channel);
            List <MessageModel> msgs = new List <MessageModel>();

            using (var call = client.GetNewMessages(new NewMessageRequest()))
            {
                while (await call.ResponseStream.MoveNext())
                {
                    var msg = call.ResponseStream.Current;
                    yield return(msg);
                }
            }
            //return await Task.FromResult(Ok("Welcome to GRPC client"));
        }