public static int Main(string[] args) { if (args.Length > 1 && args[0] == "--makeconfig") { MakeConfig(); return(0); } var config = JSON.Deserialize <Config>(File.ReadAllText("librelancerserver.config.json")); var srv = new GameServer(config.freelancer_path); srv.DbConnectionString = config.dbconnectionstring; srv.ServerName = config.server_name; srv.ServerDescription = config.server_description; srv.Start(); bool running = true; while (running) { var cmd = Console.ReadLine(); switch (cmd.Trim().ToLowerInvariant()) { case "stop": case "quit": case "exit": running = false; break; } } srv.Stop(); return(0); }
static void Main(string[] args) { var messageHandler = new CCCMessageHandlerBuilder() .AddCommandHandler(new ConnectHandler()) .AddCommandHandler(new DieHandler()) .AddCommandHandler(new PlayHandler()) .AddCommandHandler(new ListHandler()) .AddCommandHandler(new MoveHandler()) .AddFallbackHandler(new FallbackHandler()) .Build(); var server = new GameServer(new GameServerConfig { Address = IPAddress.Parse(Ip), AcceptQueueLength = 10, ListenDelay = 100, Port = Port, Handler = messageHandler, }); server.ServerStarted += OnStart; server.UserConnected += OnUserConnected; server.UserMessaged += OnUserMessaged; server.UserDisconnected += OnUserDisconnected; server.Start(); Console.ReadLine(); server.Stop(); }
// 创建实验室用的服务器,返回启动操作 public static Action BuildLibServer(GameServer gs, int port) { srv = gs; var ci = BC <ConsoleInput>(); ci.Srv = gs; BuildBaseComponents(); // 基础模块 BuildBussinessLoggers(gs); // 日志系统 BuildQuestionnaire(gs); // 问卷系统 BuildLogicComponents(gs); // 逻辑功能 BuildGMComponent(); // GM 和调试功能 // 初始化所有模块 srv.Initialize(); return(() => { // 启动服务器 srv.Get <NetCore>().StartListening("0.0.0.0", port); srv.Get <ILog>().Info("GameServer started at: " + port); srv.Start(); }); }
static void Main(string[] args) { GameServer server = new GameServer(); server.Start(); Console.WriteLine("Server has been started!"); while (true) { //Console.Write("> "); string input = Console.ReadLine(); switch (input) { case "stop": server.Stop(); Console.WriteLine("Server has been stopped!"); return; case "end": server.Game.End(); server.CancelTurnTimer(); server.SendGameOver(); Console.WriteLine("The game has been ended."); break; default: Console.WriteLine("'" + input + "' is not a valid command!"); break; } } }
static void Main(string[] args) { Console.SetWindowSize(55, 35); Database db = new Database(); GameServer gameServer = new GameServer(db); gameServer.Start(); }
public async Task StartAsync(CancellationToken cancellationToken) { if (!_gameServer.Start()) { throw new InvalidOperationException("Could not start server."); } Console.WriteLine($"Server listening for game clients at port {_gameServer.Endpoint.Address}:{_gameServer.Endpoint.Port}."); }
static int Main(string[] args) { var parser = new CommandLineParser.CommandLineParser(); var launchArguments = new LaunchArguments(); try { parser.ExtractArgumentAttributes(launchArguments); parser.ParseCommandLine(args); } catch (CommandLineException ex) { Console.WriteLine(ex.Message); parser.ShowUsage(); return(1); } if (launchArguments.MaxPlayers > SharedConstants.MaxPlayerLimit) { Console.WriteLine($"Max players exceeded max limit of {SharedConstants.MaxPlayerLimit}. Value was adjusted."); launchArguments.MaxPlayers = SharedConstants.MaxPlayerLimit; } if (launchArguments.MaxPlayers < 1) { Console.WriteLine("Player limit can't be lower than 1."); parser.ShowUsage(); return(1); } ConsoleManager.Initialize(); ConsoleManager.OnInput += cmd => queuedCommandInputs.Enqueue(cmd); Server = new GameServer(launchArguments.ServerName, launchArguments.MaxPlayers, launchArguments.Port, false, launchArguments.Private, !launchArguments.NoSteam, "config"); Server.Start(); while (Server.Running) { while (queuedCommandInputs.Count > 0) { Server.ConsoleCommands.HandleMessage(null, queuedCommandInputs.Dequeue()); } if (!Server.Running) { continue; } Server.Update(); Console.Title = $"{Server.Name} | {Server.Players.Count}/{Server.MaxPlayers}"; Thread.Sleep(1); } ConsoleManager.Destroy(); return(0); }
static void Main(string[] args) { GameServer gameServer = new GameServer("127.0.0.1", 52077); gameServer.Start(); bool run = true; while (run) { Console.Write("console >> "); DoCommandProcess(Console.ReadLine(), out run, gameServer); } Console.ReadKey(); }
static void Main(string[] args) { try { Console.Title = "Game Server"; isRunning = true; Thread mainThread = new Thread(new ThreadStart(MainThread)); mainThread.Start(); GameServer.Start(10, 26950); } catch (Exception e) { Console.WriteLine(e.ToString()); } }
public static Action BuildConsoleAgent(GameServer gs, string srvAddr, int srvPort) { srv = gs; BuildBaseComponents(); // 基础模块 var cia = BC <ConsoleInputAgent>(); // 初始化所有模块 srv.Initialize(); return(() => { // 启动服务器 cia.Start(srvAddr, srvPort); srv.Start(); }); }
private static void Main(string[] args) { Settings.Init("Resources/Data/Buildings.xml", "Resources/Data/Units.xml"); var server = new GameServer(5555); //server.SetGame(new StandardMelee(server, 1)); server.Start(); var stopwatch = new Stopwatch(); stopwatch.Restart(); while (true) { var dt = (float) (stopwatch.Elapsed.TotalSeconds*1000); stopwatch.Restart(); server.Update(dt); Thread.Sleep(100); } }
// 战斗数据分析用服务器 public static Action BuildConsoleDataAnalysis(GameServer gs, int port) { srv = gs; var cida = BC <ConsoleInputDataAnalysis>(); cida.Srv = gs; BuildBaseComponents(); // 基础模块 BuildLogicComponents(gs); // 逻辑功能 BuildDataAnalysisComponents(); // 数据分析功能 // 初始化所有模块 srv.Initialize(); return(() => { // 启动服务器 srv.Get <ILog>().Info("DataAnalysisServer started at: " + port); srv.Start(); }); }
static void Main(string[] args) { GameServer server = new GameServer(IPAddress.Loopback, 11000); server.Start(10); }
public static int Main(string[] args) { if (args.Length > 0 && args[0] == "--makeconfig") { MakeConfig(); return(0); } if (!File.Exists("librelancerserver.config.json")) { Console.Error.WriteLine("Can't find librelancerserver.config.json"); return(2); } var config = JSON.Deserialize <Config>(File.ReadAllText("librelancerserver.config.json")); config.DatabasePath = Path.GetFullPath(config.DatabasePath); var srv = new GameServer(config.FreelancerPath); var ctxFactory = new SqlDesignTimeFactory(config); if (!File.Exists(config.DatabasePath)) { FLLog.Info("Server", $"Creating database file {config.DatabasePath}"); using (var ctx = ctxFactory.CreateDbContext(new string[0])) { ctx.Database.Migrate(); } } using (var ctx = ctxFactory.CreateDbContext(new string[0])) { //Force create model early if (ctx.Database.GetPendingMigrations().Any()) { FLLog.Info("Server", "Migrating database"); ctx.Database.Migrate(); } FLLog.Debug("model", ctx.Model.ToString()); } srv.DbContextFactory = ctxFactory; srv.ServerName = config.ServerName; srv.ServerDescription = config.ServerDescription; srv.Start(); bool running = true; while (running) { var cmd = Console.ReadLine(); switch (cmd.Trim().ToLowerInvariant()) { case "stop": case "quit": case "exit": running = false; break; } } srv.Stop(); return(0); }