Exemple #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app.UseCors("AllowAll");

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseWebAssemblyDebugging();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseWebSockets();

            app.UseHttpsRedirection();
            app.UseBlazorFrameworkFiles();

            app.UseStaticFiles(new StaticFileOptions
            {
                //OnPrepareResponse = x =>
                //{
                //    x.Context.Response.Headers[HeaderNames.CacheControl] = "no-store";
                //}
            });

            app.UseRouting();

            app.UseAuthorization();
            app.UseAuthentication();

            app.UseEndpoints(endpoints =>
            {
                //endpoints.MapBlazorHub();
                endpoints.MapRazorPages();
                endpoints.MapControllers();
                endpoints.MapFallbackToFile("index.html");
                endpoints.MapHub <PlanetHub>(PlanetHub.HubUrl, options =>
                {
                    //options.LongPolling.PollTimeout = TimeSpan.FromSeconds(60);
                });
            });

            PlanetHub.Current = app.ApplicationServices.GetService <IHubContext <PlanetHub> >();

            /* Reference code for any future migrations */

            using (ValourDB db = new ValourDB(ValourDB.DBOptions))
            {
                foreach (ServerPlanetRole role in db.PlanetRoles.Include(x => x.Planet))
                {
                    if (role.Id == role.Planet.Default_Role_Id)
                    {
                        role.Position = uint.MaxValue;
                    }
                }

                db.SaveChanges();
            }
        }