SES-77 SignalR base config

This commit is contained in:
Łukasz Góreczny 2020-12-05 18:55:35 +01:00
parent 21710903ed
commit 561b688519
2 changed files with 21 additions and 1 deletions

View File

@ -0,0 +1,12 @@
using Microsoft.AspNetCore.SignalR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace SessionCompanion.Hubs
{
public class SessionHub : Hub
{
}
}

View File

@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http.Connections;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.SpaServices.AngularCli;
using Microsoft.EntityFrameworkCore;
@ -8,6 +9,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SessionCompanion.Configurations;
using SessionCompanion.Database;
using SessionCompanion.Hubs;
namespace SessionCompanion
{
@ -29,7 +31,7 @@ namespace SessionCompanion
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection")));
services.AddRepositories();
services.AddSignalR();
// In production, the Angular files will be served from this directory
services.AddSpaStaticFiles(configuration =>
{
@ -70,6 +72,12 @@ namespace SessionCompanion
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller}/{action=Index}/{id?}");
endpoints.MapHub<SessionHub>("/sessionhub", options =>
{
options.Transports =
HttpTransportType.WebSockets |
HttpTransportType.LongPolling;
});
});
app.UseSpa(spa =>