static void Main(string[] args) { Options options = null; { var parse_result = Parser.Default.ParseArguments <Options>(args); parse_result .WithParsed(opts => options = opts) .WithNotParsed((errors) => Options.ThrowErrorMsg(errors)); } Log.Backend = new ConsoleLogger(); var port_allocator = PortAllocator.Create(options.port_base, options.port_top); var service = new ArenaHostPrivateServiceImpl(options.unity_file, options.self_url, port_allocator); var server = new Server { Services = { ArenaServer.ArenaHostServicePrivate.BindService(service) }, Ports = { new ServerPort("localhost", options.host_port, ServerCredentials.Insecure) } }; server.Start(); Log.Msg("Server is now running..."); Log.Msg("Press any key to stop the server."); Console.ReadKey(); Log.Msg("Stopping server..."); server.ShutdownAsync().Wait(); Log.Msg("Successfully stopped server..."); Log.Msg("Remember the arenas owned by this server can still be running."); }
internal ArenaHostPrivateServiceImpl(string invoke_unity_file, string self_url, PortAllocator port_allocator) { this.invoke_unity_file = invoke_unity_file ?? throw new ArgumentNullException(nameof(invoke_unity_file)); this.self_url = self_url ?? throw new ArgumentNullException(nameof(self_url)); this.port_allocator = port_allocator; }