public static void RegistAppInstance(ServerControlManagementService ManagementService,BahamutAppInstance appInstance)
 {
     if (BahamutAppInstanceRegister.ManagementService == null)
     {
         BahamutAppInstanceRegister.ManagementService = ManagementService;
     }
     Task.Run(async () =>
     {
         try
         {
             await ManagementService.RegistAppInstanceAsync(appInstance);
             var observer = ManagementService.StartKeepAlive(appInstance);
             observer.OnExpireError += KeepAliveObserver_OnExpireError;
             observer.OnExpireOnce += KeepAliveObserver_OnExpireOnce;
             LogManager.GetLogger("Main").Info("Bahamut App Instance:" + appInstance.Id.ToString());
             LogManager.GetLogger("Main").Info("Keep Server Instance Alive To Server Controller Thread Started!");
         }
         catch (Exception ex)
         {
             LogManager.GetLogger("Main").Error(ex, "Unable To Regist App Instance");
         }
     });
 }
Example #2
0
        // This method gets called by a runtime.
        // Use this method to add services to the container
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc(config => {
                config.Filters.Add(new LogExceptionFilter());
            }).AddJsonOptions(x =>
            {
                x.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
                x.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
                x.SerializerSettings.Formatting = Formatting.None;
            });

            services.AddScoped<LogExceptionFilter>();

            services.AddSingleton(new FireService(DBClientManagerBuilder.GeneratePoolMongodbClient(Configuration.GetSection("Data:BahamutFireDBServer"))));

            var TokenServerClientManager = DBClientManagerBuilder.GenerateRedisConnectionMultiplexer(Configuration.GetSection("Data:TokenServer"));
            var tokenService = new TokenService(TokenServerClientManager);
            services.AddSingleton(tokenService);

            var ControlServerServiceClientManager = DBClientManagerBuilder.GenerateRedisConnectionMultiplexer(Configuration.GetSection("Data:ControlServiceServer"));
            var serverControlMgrService = new ServerControlManagementService(ControlServerServiceClientManager);
            services.AddSingleton(serverControlMgrService);
        }