public ByeRequest(Sender.SenderClient senderClient) { if (senderClient == null) { throw new ArgumentNullException(nameof(senderClient)); } _senderClient = senderClient; }
static async Task Main(string[] args) { var channel = GrpcChannel.ForAddress("https://localhost:5001"); Sender.SenderClient client = new Sender.SenderClient(channel); var demoOperations = new Dictionary <ConsoleKey, IClientSample> { [ConsoleKey.D1] = new HelloRequest(client), [ConsoleKey.D2] = new PingRequest(client), [ConsoleKey.D3] = new ByeRequest(client), [ConsoleKey.D4] = new BadRequest(client) }; ConsoleKeyInfo consoleKeyInfo; do { ShowConsoleMenu(); consoleKeyInfo = Console.ReadKey(false); if (demoOperations.ContainsKey(consoleKeyInfo.Key)) { Console.Clear(); //exception handling! var replies = await demoOperations[consoleKeyInfo.Key].Show(); //this can be refactored to process response asynchronous await foreach (var reply in replies.ResponseStream.ReadAllAsync()) { Console.WriteLine(reply.Message); } } else { Console.WriteLine("invalid choice! please try again :)"); } } while (consoleKeyInfo.Key != ConsoleKey.Escape); Console.WriteLine("Done. Press any key to exit..."); Console.ReadKey(); }