// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly()); XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config")); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); //app.UseBrowserLink(); } else { app.UseHsts(); } app.UseDefaultFiles(); app.UseStaticFiles(); WebSocketOptions webSocketOptions = new WebSocketOptions() { KeepAliveInterval = TimeSpan.FromSeconds(60), ReceiveBufferSize = 8192 }; //enable websocket with prior declared options app.UseWebSockets(webSocketOptions); app.UseMvc(); //use self defined policy(see Configure Services) for Cross-Origin Resource Sharing (CORS) app.UseCors("MyPolicy"); Config config = Config.loadConfig(); ThreadPool.SetMinThreads(config.maxUsers, config.maxUsers); app.Use(async(context, next) => { //catch http requests at /server and check if it is a websocket request if (context.Request.Path == "/server") { if (context.WebSockets.IsWebSocketRequest) { WebSocket webSocket = await context.WebSockets.AcceptWebSocketAsync(); //every websocket has its own SocketHandler SocketHandler doorSocket = new SocketHandler(); await doorSocket.socketHandle(context, webSocket); } else { await next(); } } }); }
private GameHandler() { this.config = Config.loadConfig(); this.timer = new Timer(config.roundDuration); if (config.databaseType.ToLower() == "mysql") { this.dataStorage = new MySQLHandler(); Console.WriteLine("Enabled MYSQL"); } else { this.dataStorage = new DBQueryDummy(); Console.WriteLine("Dummy DB"); } Game lastgame = dataStorage.loadLastGameData(); this.game = new Game(lastgame == null ? 1 : lastgame.id + 1); }
public MySQLHandler() { this.config = Config.loadConfig(); this.ConnectionString = config.connectionString; }