Implemented power state and task streaming over signalr
This commit is contained in:
@@ -6,6 +6,7 @@ using MoonCore.Extensions;
|
||||
using MoonCore.Helpers;
|
||||
using MoonCore.Services;
|
||||
using MoonlightServers.Daemon.Configuration;
|
||||
using MoonlightServers.Daemon.Http.Hubs;
|
||||
using MoonlightServers.Daemon.Services;
|
||||
|
||||
namespace MoonlightServers.Daemon;
|
||||
@@ -43,13 +44,17 @@ public class Startup
|
||||
await RegisterBase();
|
||||
await RegisterDocker();
|
||||
await RegisterServers();
|
||||
await RegisterSignalR();
|
||||
await RegisterCors();
|
||||
|
||||
await BuildWebApplication();
|
||||
|
||||
await UseBase();
|
||||
await UseCors();
|
||||
await UseBaseMiddleware();
|
||||
|
||||
await MapBase();
|
||||
await MapHubs();
|
||||
|
||||
await WebApplication.RunAsync();
|
||||
}
|
||||
@@ -71,7 +76,6 @@ public class Startup
|
||||
WebApplicationBuilder.Services.AddControllers();
|
||||
|
||||
WebApplicationBuilder.Services.AddApiExceptionHandler();
|
||||
WebApplicationBuilder.Services.AddSignalR();
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
@@ -248,7 +252,7 @@ public class Startup
|
||||
WebApplicationBuilder.Services.AddHostedService<ApplicationStateService>(
|
||||
sp => sp.GetRequiredService<ApplicationStateService>()
|
||||
);
|
||||
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@@ -258,4 +262,43 @@ public class Startup
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Maps
|
||||
|
||||
private Task RegisterSignalR()
|
||||
{
|
||||
WebApplicationBuilder.Services.AddSignalR();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task MapHubs()
|
||||
{
|
||||
WebApplication.MapHub<ServerConsoleHub>("api/servers/console");
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cors
|
||||
|
||||
private Task RegisterCors()
|
||||
{
|
||||
//TODO: IMPORTANT: CHANGE !!!
|
||||
WebApplicationBuilder.Services.AddCors(x =>
|
||||
x.AddDefaultPolicy(builder =>
|
||||
builder.AllowAnyHeader().AllowAnyOrigin().AllowAnyMethod().Build()
|
||||
)
|
||||
);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task UseCors()
|
||||
{
|
||||
WebApplication.UseCors();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user