// only call before Start() public int AddListeningPort(string addr, ServerCredentials credentials) { using (var nativeCredentials = credentials.ToNativeCredentials()) { return handle.AddListeningPort(addr, nativeCredentials); } }
// only call before Start() public int AddListeningPort(string addr, ServerCredentials credentials) { using (var nativeCredentials = credentials.ToNativeCredentials()) { return(handle.AddListeningPort(addr, nativeCredentials)); } }
/// <summary> /// Creates a port from an existing <c>ServerPort</c> instance and boundPort value. /// </summary> internal ServerPort(ServerPort serverPort, int boundPort) { this.host = serverPort.host; this.port = serverPort.port; this.credentials = serverPort.credentials; this.boundPort = boundPort; }
/// <summary> /// Creates a port from an existing <c>ServerPort</c> instance and boundPort value. /// </summary> internal ServerPort(ServerPort serverPort, int boundPort) { this.host = serverPort.host; this.port = serverPort.port; this.credentials = serverPort.credentials; this.boundPort = boundPort; }
/// <summary> /// Add a secure port on which server should listen. /// Only call this before Start(). /// </summary> public int AddListeningPort(string addr, ServerCredentials credentials) { lock (myLock) { Preconditions.CheckState(!startRequested); using (var nativeCredentials = credentials.ToNativeCredentials()) { return(handle.AddListeningPort(addr, nativeCredentials)); } } }
private int AddListeningPortInternal(string host, int port, ServerCredentials credentials) { lock (myLock) { Preconditions.CheckState(!startRequested); var address = string.Format("{0}:{1}", host, port); if (credentials != null) { using (var nativeCredentials = credentials.ToNativeCredentials()) { return(handle.AddListeningPort(address, nativeCredentials)); } } else { return(handle.AddListeningPort(address)); } } }
private int AddListeningPortInternal(string host, int port, ServerCredentials credentials) { lock (myLock) { Preconditions.CheckState(!startRequested); var address = string.Format("{0}:{1}", host, port); if (credentials != null) { using (var nativeCredentials = credentials.ToNativeCredentials()) { return handle.AddListeningPort(address, nativeCredentials); } } else { return handle.AddListeningPort(address); } } }
/// <summary> /// Add a non-secure port on which server should listen. /// Only call this before Start(). /// </summary> /// <returns>The port on which server will be listening.</returns> /// <param name="host">the host</param> /// <param name="port">the port. If zero, an unused port is chosen automatically.</param> public int AddListeningPort(string host, int port, ServerCredentials credentials) { Preconditions.CheckNotNull(credentials); return AddListeningPortInternal(host, port, credentials); }
/// <summary> /// Creates a new port on which server should listen. /// </summary> /// <returns>The port on which server will be listening.</returns> /// <param name="host">the host</param> /// <param name="port">the port. If zero, an unused port is chosen automatically.</param> /// <param name="credentials">credentials to use to secure this port.</param> public ServerPort(string host, int port, ServerCredentials credentials) { this.host = GrpcPreconditions.CheckNotNull(host, "host"); this.port = port; this.credentials = GrpcPreconditions.CheckNotNull(credentials, "credentials"); }
/// <summary> /// Creates a new port on which server should listen. /// </summary> /// <returns>The port on which server will be listening.</returns> /// <param name="host">the host</param> /// <param name="port">the port. If zero, an unused port is chosen automatically.</param> /// <param name="credentials">credentials to use to secure this port.</param> public ServerPort(string host, int port, ServerCredentials credentials) { this.host = Preconditions.CheckNotNull(host, "host"); this.port = port; this.credentials = Preconditions.CheckNotNull(credentials, "credentials"); }
/// <summary> /// Adds a new port on which server should listen. /// <returns>The port on which server will be listening.</returns> /// </summary> /// <param name="host">the host</param> /// <param name="port">the port. If zero, an unused port is chosen automatically.</param> /// <param name="credentials">credentials to use to secure this port.</param> public int Add(string host, int port, ServerCredentials credentials) { return(Add(new ServerPort(host, port, credentials))); }
/// <summary> /// Add a non-secure port on which server should listen. /// Only call this before Start(). /// </summary> /// <returns>The port on which server will be listening.</returns> /// <param name="host">the host</param> /// <param name="port">the port. If zero, , an unused port is chosen automatically.</param> public int AddListeningPort(string host, int port, ServerCredentials credentials) { Preconditions.CheckNotNull(credentials); return(AddListeningPortInternal(host, port, credentials)); }
/// <summary> /// /// </summary> /// <param name="args"></param> static void Main(string[] args) { Server server = new Server(); try { SampleServerSettings settings = SampleServerSettings.LoadFromFile("SampleServerSettings.config"); //ServiceTimeFillterAttribute.DefaultOpenTime = null; //ServiceTimeFillterAttribute.DefaultCloseTime = null; // regist service. GrpcServiceBuilder builder = new GrpcServiceBuilder(); GrpcServiceBuilderSettings builderSettings = new GrpcServiceBuilderSettings(); builderSettings.MarshallerFactory = GrpcMarshallerFactory.DefaultInstance; builderSettings.PerformanceListener = new GrpcServerPerformanceListener(); RegistPerformanceEventHandlers(builderSettings.PerformanceListener); server.Services.Add(builder.BuildService("PlayerSearch", typeof(PlayerSearch), new PlayerSearchServiceImpl(), builderSettings)); // regist heartbeat. server.Services.Add(GrpcHeartbeat.BuildService()); // start server. Grpc.Core.ServerCredentials credential = Grpc.Core.ServerCredentials.Insecure; server.Ports.Add(settings.ServerName, settings.ServerPort, credential); Console.WriteLine(string.Format("Starting... {0}:{1}", settings.ServerName, settings.ServerPort)); server.Start(); Console.WriteLine("Started."); Console.WriteLine("If you want to shutdown, please press any key."); Console.ReadLine(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { Console.WriteLine("In shutdown..."); try { if (server != null) { server.ShutdownAsync().Wait(); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } Console.WriteLine("Shutdown completed."); } Console.WriteLine("If you want to close, please press any key."); Console.ReadLine(); }
/// <summary> /// Add a port on which server should listen. /// Only call this before Start(). /// </summary> /// <returns>The port on which server will be listening.</returns> /// <param name="host">the host</param> /// <param name="port">the port. If zero, an unused port is chosen automatically.</param> public int AddPort(string host, int port, ServerCredentials credentials) { lock (myLock) { Preconditions.CheckNotNull(credentials); Preconditions.CheckState(!startRequested); var address = string.Format("{0}:{1}", host, port); using (var nativeCredentials = credentials.ToNativeCredentials()) { if (nativeCredentials != null) { return handle.AddSecurePort(address, nativeCredentials); } else { return handle.AddInsecurePort(address); } } } }