コード例 #1
0
        public async Task DuplexStreamingCall(Status status = Status.Ok)
        {
            try
            {
                using (AsyncDuplexStreamingCall <PingRequest, PingResponse> call = _client.DuplexPing())
                {
                    Task responseReaderTask = Task.Run(async() =>
                    {
                        while (call != null && await call.ResponseStream.MoveNext())
                        {
                        }
                    });

                    await call.RequestStream.WriteAsync(new PingRequest()
                    {
                        Status = status
                    });

                    await call.RequestStream.WriteAsync(new PingRequest()
                    {
                        Status = status
                    });

                    await call.RequestStream.CompleteAsync();

                    await responseReaderTask;
                }
            }
            catch (Exception)
            {
                // ignored
            }
        }
コード例 #2
0
 public async Task UnaryCallAsync(Status status = Status.Ok)
 {
     try
     {
         await _client.UnaryPingAsync(new PingRequest()
         {
             Status = status
         });
     }
     catch (Exception)
     {
         // ignored
     }
 }
コード例 #3
0
 public void UnaryCall(Status status = Status.Ok)
 {
     try
     {
         _client.UnaryPing(new PingRequest()
         {
             Status = status
         });
     }
     catch (Exception)
     {
         // ignored
     }
 }
コード例 #4
0
 public async Task ServerStreamingCall(Status status = Status.Ok)
 {
     try
     {
         using (AsyncServerStreamingCall <PingResponse> call =
                    _client.ServerStreamingPing(new PingRequest()
         {
             Status = status
         }))
         {
             while (await call.ResponseStream.MoveNext(CancellationToken.None))
             {
             }
         }
     }
     catch (Exception)
     {
         // ignored
     }
 }
コード例 #5
0
        public async Task ClientStreamingCall(Status status = Status.Ok)
        {
            try
            {
                using (AsyncClientStreamingCall <PingRequest, PingResponse> call = _client.ClientStreamingPing())
                {
                    await call.RequestStream.WriteAsync(new PingRequest()
                    {
                        Status = status
                    });

                    await call.RequestStream.CompleteAsync();

                    await call.ResponseAsync;
                }
            }
            catch (Exception)
            {
                // ignored
            }
        }