private static async Task SendTime(TimePingRequest request, IServerStreamWriter <TimePingResponse> responseStream) { await responseStream.WriteAsync(new TimePingResponse() { Message = $"Its now:", TimeNow = Timestamp.FromDateTimeOffset(DateTimeOffset.Now) }).ConfigureAwait(false); }
public override async Task TimePing(TimePingRequest request, IServerStreamWriter <TimePingResponse> responseStream, ServerCallContext context) { await responseStream.WriteAsync(new TimePingResponse() { Message = $"Hello {request.ClientName}. You are connected and will get a time information every 5 seconds from now", TimeNow = Timestamp.FromDateTimeOffset(DateTimeOffset.Now) }); while (!context.CancellationToken.IsCancellationRequested) { await responseStream.WriteAsync(new TimePingResponse() { Message = $"Its now:", TimeNow = Timestamp.FromDateTimeOffset(DateTimeOffset.Now) }).ConfigureAwait(false); await Task.Delay(TimeSpan.FromSeconds(5)).ConfigureAwait(false); } }