static async Task Main(string[] args) { Console.BackgroundColor = ConsoleColor.Green; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Hello gRPC Sender!"); const string url = "https://localhost:5001"; var channel = GrpcChannel.ForAddress(url); var client = new ChatterService.ChatterManager.ChatterManagerClient(channel); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); for (int i = 0; i < 10000; i++) { ChatterService.ChatMessage chatMessage = new ChatterService.ChatMessage { Content = $"Temp {i}" }; await client.SendMessage().RequestStream.WriteAsync(chatMessage); } stopwatch.Stop(); Console.WriteLine($"elapsed time: {stopwatch.Elapsed}"); Console.ReadKey(); Console.ResetColor(); }
static async Task Main(string[] args) { Console.BackgroundColor = ConsoleColor.Blue; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Hello gRPC Receiver!"); const string url = "https://localhost:5001"; var channel = GrpcChannel.ForAddress(url); var client = new ChatterService.ChatterManager.ChatterManagerClient(channel); var stream = client.SendMessage().ResponseStream.ReadAllAsync(); await foreach (var message in stream) { Console.WriteLine(message.Content); } Console.WriteLine("Press any key to exit."); Console.ReadKey(); Console.ResetColor(); }