private static async Task Main(string[] args) { var credentials = TestCertificates.GrpcSslCredentials; var sslOptions = TestCertificates.SslClientOptions; var connectionManager = new RpcConnectionManager( new IRpcConnectionProvider[] { new SciTech.Rpc.Grpc.Client.GrpcConnectionProvider(credentials), new SciTech.Rpc.Lightweight.Client.LightweightConnectionProvider(sslOptions) }); var connection = new NamedPipeRpcConnection("Test"); connection.GetServiceSingleton <IGreeterServiceClient>(); RpcConnectionInfo connectionInfo = Client.RpcExamplesHelper.RetrieveConnectionInfo(); var greeter = connectionManager.GetServiceSingleton <IGreeterServiceClient>(connectionInfo); var reply = greeter.SayHello("GreeterClient"); Console.WriteLine(); Console.WriteLine(reply); Console.WriteLine(); Console.WriteLine("Shutting down"); await connectionManager.ShutdownAsync().ConfigureAwait(false); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); //var server = new LightweightRpcServer(); //server.AddEndPoint(new NamedPipeRpcEndPoint("GreeterPipe")); //server.PublishSingleton<IGreeterService>(new GreeterServiceImpl()); //server.Start(); //Console.WriteLine("Press any key to exit..."); //Console.ReadKey(); //var connection = new NamedPipeRpcConnection("GreeterPipe"); //var greeter2 = connection.GetServiceSingleton<IGreeterServiceClient>(); }
private static async Task Main(string[] args) { var mailboxName = GetMailboxName(args); var credentials = TestCertificates.GrpcSslCredentials; var sslOptions = TestCertificates.SslClientOptions; var connectionManager = new RpcConnectionManager( new IRpcConnectionProvider[] { new SciTech.Rpc.Grpc.Client.GrpcConnectionProvider(credentials), new SciTech.Rpc.Lightweight.Client.LightweightConnectionProvider(sslOptions) }); var connectionInfo = Client.RpcExamplesHelper.RetrieveConnectionInfo(); Console.WriteLine($"Connecting to mailbox '{mailboxName}'"); Console.WriteLine(); var mailBoxManager = connectionManager.GetServiceSingleton <IMailBoxManagerServiceClient>(connectionInfo); //await mailBoxManager.ConnectAsync(); Console.WriteLine("Connected"); Console.WriteLine("Press escape to disconnect. Press any other key to forward mail."); using (var mailbox = await mailBoxManager.GetMailboxAsync(mailboxName)) { mailbox.MailReceieved += (s, msg) => { Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(); Console.WriteLine("Mail received"); Console.WriteLine($"New mail: {msg.New}, Forwarded mail: {msg.Forwarded}"); Console.ResetColor(); }; mailbox.MailForwarded += (s, msg) => { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(); Console.WriteLine("Mail forwarded"); Console.WriteLine($"New mail: {msg.New}, Forwarded mail: {msg.Forwarded}"); Console.ResetColor(); }; while (true) { var result = Console.ReadKey(intercept: true); if (result.Key == ConsoleKey.Escape) { break; } await mailbox.ForwardMailAsync(); } } Console.WriteLine("Disconnecting"); await connectionManager.ShutdownAsync(); Console.WriteLine("Disconnected. Press any key to exit."); Console.ReadKey(); }