Example #1
0
        static void Main(string[] args)
        {
            GameServer gameServer = new GameServer();

            gameServer.StartUp();
            Console.WriteLine("游戏服务器已启动。");
            Console.WriteLine("请按Ctrl+C退出服务器");
            Console.CancelKeyPress += (sender, e) =>
            {
                Console.WriteLine("正在关闭游戏服务器");
                gameServer = null;
                Console.WriteLine("游戏服务器已关闭");
                System.Threading.Thread.Sleep(1000);
            };
            while (true)
            {
                //read string and do something
                Console.ReadLine();
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            LoadConfig();

            var serviceProvider = new ServiceCollection()
                                  .AddMediatR(typeof(Resolver).GetTypeInfo().Assembly)
                                  .AddScoped <IMediator, Mediator>()
                                  .AddScoped <IColonistPickGetter, ColonistPickGetter>()
                                  .AddScoped <IDrawGetter, DrawGetter>()
                                  .AddScoped <IDiscardGetter, DiscardGetter>()
                                  .AddScoped <IPowerGetter, PowerGetter>()
                                  .AddScoped <IBuildGetter, BuildGetter>()
                                  .AddScoped <IGameEndGetter, GameEndGetter>()
                                  .BuildServiceProvider();

            var mediator = serviceProvider.GetService <IMediator>();

            var server = new GameServer(mediator, serviceProvider);

            server.StartUp(
                IPAddress.Parse(configuration.GetSection(API_CONFIG_SECTION)[API_CONFIG_NAME_IP]),
                int.Parse(configuration.GetSection(API_CONFIG_SECTION)[API_CONFIG_NAME_PORT]));  // start the server
        }