static void Main(string[] args) { Channel channel = null; try { channel = new Channel(target, ChannelCredentials.Insecure); channel.ConnectAsync().ContinueWith(task => { if (task.Status == System.Threading.Tasks.TaskStatus.RanToCompletion) { Console.WriteLine("Client Connection Success!!!"); } }); var client = new DummyService.DummyServiceClient(channel); channel.ShutdownAsync().Wait(); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine("Failed for reason", ex.Message); throw; } }
//const string target = "127.0.0.1:50052"; static async Task Main(string[] args) { var clientCertificate = File.ReadAllText("ssl/client.crt"); var clientKey = File.ReadAllText("ssl/client.key"); var caCertificate = File.ReadAllText("ssl/ca.crt"); var channelCredentials = new SslCredentials(caCertificate, new KeyCertificatePair(clientCertificate, clientKey)); //Channel channel = new Channel(target, channelCredentials); Channel channel = new Channel("localhost", 50052, ChannelCredentials.Insecure); await channel.ConnectAsync().ContinueWith((task) => { if (task.Status == TaskStatus.RanToCompletion) { Console.WriteLine("The client connected successfully"); } }); var dummyClient = new DummyService.DummyServiceClient(channel); var greetingClient = new GreetingService.GreetingServiceClient(channel); Greet(greetingClient); //await GreetMany(greetingClient); //await LongGreet(greetingClient); //await GreetEveryOne(greetingClient); //GreetWithDeadline(greetingClient); var calculatorClient = new CalculatorService.CalculatorServiceClient(channel); //Add(calculatorClient); //await PrimeNoDecomp(calculatorClient); //await ComputeAverage(calculatorClient); //await FindMaximum(calculatorClient); //Sqrt(calculatorClient); var blogClient = new BlogService.BlogServiceClient(channel); //var newBlog = CreateBlog(blogClient); //ReadBlog(blogClient); //UpdateBlog(blogClient, newBlog); //DeleteBlog(blogClient, newBlog); await ListBlog(blogClient); channel.ShutdownAsync().Wait(); Console.ReadKey(); }