static async Task Main(string[] args) { //We need this switch because we are connecting to an unsecure server. If the server runs on SSL, there's no need for this switch. AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); var channel = GrpcChannel.ForAddress("http://localhost:5000"); var client = new Board.BoardClient(channel); var request = new MessageRequest(); request.Capabilities.Add(new MessageRequest.Types.SuperPower { Name = "Flying", Level = 1 }); request.Capabilities.Add(new MessageRequest.Types.SuperPower { Name = "Invisibility", Level = 10 }); request.Capabilities.Add(new MessageRequest.Types.SuperPower { Name = "Speed", Level = 5 }); var reply = await client.ShowMessageAsync(request); var displayDate = new DateTime(reply.ReceivedTime); Console.WriteLine( $"We sent a message to a gRPC server and received the following reply \n'\n{reply.Message}' \non {displayDate} "); Console.WriteLine("End"); Console.Read(); }
static async Task Main(string[] args) { //We need this switch because we are connecting to an unsecure server. If the server runs on SSL, there's no need for this switch. AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); var channel = GrpcChannel.ForAddress("http://localhost:5000"); var client = new Board.BoardClient(channel); var reply = await client.ShowMessageAsync(new MessageRequest { Message = "Good morning people of the world", Sender = "Dody Gunawinata" }); var displayDate = new DateTime(reply.DisplayTime); Console.WriteLine($"This server sends a gRPC request to a server and get the following result: Received message on {displayDate} from {reply.ReceiveFrom}"); Console.ReadLine(); }
static async Task Main(string[] args) { //We need this switch because we are connecting to an unsecure server. If the server runs on SSL, there's no need for this switch. AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); var channel = GrpcChannel.ForAddress("http://localhost:5000"); var client = new Board.BoardClient(channel); var reply = await client.ShowMessageAsync(new MessageRequest { Message = "Hello World", Sender = "Dody Gunawinata", Type = MessageRequest.Types.MessageType.LongForm }); var displayDate = new DateTime(reply.ReceivedTime); Console.WriteLine( $"We sent a message to a gRPC server and received the following reply '{reply.Message}' on {displayDate} "); Console.WriteLine("End"); Console.Read(); }