I am using .NET Core 3.1 and want to create a GRPC Service with a Console App as the Server and a WPF App as the Client.
I can't see any examples online - for some reason all the Console Apps seem to connect and send messages, none are Servers.
Is it possible to have a Console App starting the Service and a WPF App connecting and sending a message to it?
I have downloaded below project and am trying to see if I can get a Console App to be the Server. [GRPC in .NET Core][1]
Any pointers appreciated. [1]: https://www.jenx.si/2019/06/14/experimenting-with-grpc-in-net-core/
The Console App below is now the Server but I am not able to read and store the Payload from the Client in the Main function - I can see it is received in from the Client.
How can I store the payload message from the client in the Main function?
//Console App Main function listening for
static async Task Main(string[] args)
{
_gRpcServer = new Server
{
Services ={Jenx.Grpc.SimpleDemo.Contracts.JenxSimpleGrpcService.BindService(new ConsoleAppGrpcClient())},
Ports = {new ServerPort("localhost", 505050, ServerCredentials.Insecure)}
};
}
//receives Client Message successfully
public override Task<ReplyMessage> SendMessage(RequestMessage request, ServerCallContext context)
{
Console.WriteLine($"Message Received: {request.RequestPayload}");
Console.WriteLine("Sending message back to the client...");
//<<---need to Store below in variable and return to Main function above--->>
return Task.FromResult(new ReplyMessage { ResponsePayload = $"ServerSideTime is {DateTime.Now}" });
}
I hope you are well. About your ask, you can create a Console programm and use them to host a WCF Service to publish access to Client WPF or WinForm Client. In this architecture, you have 3 layers. The Database Layer, the middle Business Layer and Client Layer and the connection can be over TCP, or HTTPS, as you configure the End Points. Also it's possible host the WCF in a Windows Service or Daemon. In .NET Core I think you can create WCF service or similar and host them in a Console Program or Service.