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)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/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.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapHub <PcHub>("/pchub");
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });

            app.Use(async(context, next) =>
            {
                var hubContext = context.RequestServices
                                 .GetRequiredService <IHubContext <PcHub> >();

                PcManager.InitTimerHubContext(hubContext);
            });
        }
Exemple #2
0
 public async Task StopTimer()
 {
     PcManager.StopTimer();
     await Clients.All.SendAsync("ServerMsg", "Timer stopped.");
 }
Exemple #3
0
 public async Task StartTimer(int seconds)
 {
     PcManager.StartTimer(seconds);
     await Clients.All.SendAsync("ServerMsg", "Timer started at rate of " + seconds + " seconds.");
 }
Exemple #4
0
 public async Task ClearBoard()
 {
     PcManager.ClearBoard();
     await Clients.All.SendAsync("SendBoard", PcManager.SerializeBoard());
 }
Exemple #5
0
 public async Task NextState()
 {
     PcManager.NextState();
     await Clients.All.SendAsync("SendBoard", PcManager.SerializeBoard());
 }
Exemple #6
0
 public async Task SetCell(string color, byte x, byte y)
 {
     PcManager.SetCell(color, x, y);
     await Clients.All.SendAsync("SendBoard", PcManager.SerializeBoard());
 }