Added hub to send datetime on front

This commit is contained in:
2026-04-12 13:34:13 +01:00
parent a17170abab
commit cd0dd8d7e1
2 changed files with 18 additions and 1 deletions
+15
View File
@@ -0,0 +1,15 @@
using Microsoft.AspNetCore.SignalR;
namespace BeReadyBackend.Hubs;
public class TimeHub : Hub
{
public async Task SendTime()
{
while (true)
{
await Clients.All.SendAsync("ReceiveTime", DateTime.Now);
await Task.Delay(1000);
}
}
}
+3 -1
View File
@@ -25,7 +25,8 @@ builder.Services
.WithOrigins("http://localhost:4200")
.WithMethods("GET", "POST", "PUT", "DELETE", "PATCH")
.AllowAnyHeader()
.WithExposedHeaders(HeaderNames.ContentDisposition);
.WithExposedHeaders(HeaderNames.ContentDisposition)
.AllowCredentials();
});
})
.SwaggerDocument(options => { options.ShortSchemaNames = true; });
@@ -71,6 +72,7 @@ app.UseAuthentication()
.UseSwaggerGen();
app.MapHub<GroupHub>("/groupHub");
app.MapHub<TimeHub>("/timeHub");
//app.UseHttpsRedirection();