Added hub to send datetime on front
This commit is contained in:
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,7 +25,8 @@ builder.Services
|
|||||||
.WithOrigins("http://localhost:4200")
|
.WithOrigins("http://localhost:4200")
|
||||||
.WithMethods("GET", "POST", "PUT", "DELETE", "PATCH")
|
.WithMethods("GET", "POST", "PUT", "DELETE", "PATCH")
|
||||||
.AllowAnyHeader()
|
.AllowAnyHeader()
|
||||||
.WithExposedHeaders(HeaderNames.ContentDisposition);
|
.WithExposedHeaders(HeaderNames.ContentDisposition)
|
||||||
|
.AllowCredentials();
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.SwaggerDocument(options => { options.ShortSchemaNames = true; });
|
.SwaggerDocument(options => { options.ShortSchemaNames = true; });
|
||||||
@@ -71,6 +72,7 @@ app.UseAuthentication()
|
|||||||
.UseSwaggerGen();
|
.UseSwaggerGen();
|
||||||
|
|
||||||
app.MapHub<GroupHub>("/groupHub");
|
app.MapHub<GroupHub>("/groupHub");
|
||||||
|
app.MapHub<TimeHub>("/timeHub");
|
||||||
|
|
||||||
//app.UseHttpsRedirection();
|
//app.UseHttpsRedirection();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user