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 } }
public async Task UnaryCallAsync(Status status = Status.Ok) { try { await _client.UnaryPingAsync(new PingRequest() { Status = status }); } catch (Exception) { // ignored } }
public void UnaryCall(Status status = Status.Ok) { try { _client.UnaryPing(new PingRequest() { Status = status }); } catch (Exception) { // ignored } }
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 } }
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 } }