|
@@ -14,6 +14,8 @@ using Microsoft.OpenApi.Models;
|
|
|
using MTWorkHR.API.Swagger;
|
|
|
using Azure.Storage.Blobs;
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
+using MTWorkHR.API.Chat;
|
|
|
+using Microsoft.AspNetCore.SignalR;
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
var config = new AppSettingsConfiguration();
|
|
@@ -97,7 +99,10 @@ builder.Services.AddSwaggerGen(swagger =>
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
-
|
|
|
+builder.Services.AddSignalR(options =>
|
|
|
+{
|
|
|
+ options.EnableDetailedErrors = true;
|
|
|
+});
|
|
|
//--------------------------
|
|
|
var app = builder.Build();
|
|
|
|
|
@@ -115,10 +120,18 @@ app.UseCors(x => x
|
|
|
.SetIsOriginAllowed(origin =>
|
|
|
true) // allow any origin
|
|
|
.AllowCredentials()); // allow credentials
|
|
|
+
|
|
|
+
|
|
|
+app.MapPost("broadcast", async (string message, IHubContext<ChatHub, IChatClient> context) =>
|
|
|
+{
|
|
|
+ await context.Clients.All.ReceiveMessage(message);
|
|
|
+ return Results.NoContent();
|
|
|
+});
|
|
|
app.UseHttpsRedirection();
|
|
|
app.UseAuthentication();
|
|
|
app.UseAuthorization();
|
|
|
app.UseMiddleware<LoggingMiddleware>();
|
|
|
app.MapControllers();
|
|
|
+app.MapHub<ChatHub>("chat-hub");
|
|
|
|
|
|
app.Run();
|