Compare commits
1 Commits
agent/hex/
...
agent/dex/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
38b7d13312 |
21
backend/.gitignore
vendored
Normal file
21
backend/.gitignore
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
## .NET
|
||||
bin/
|
||||
obj/
|
||||
*.user
|
||||
*.suo
|
||||
*.cache
|
||||
*.dll
|
||||
*.pdb
|
||||
|
||||
## IDE
|
||||
.vs/
|
||||
.idea/
|
||||
*.swp
|
||||
*~
|
||||
|
||||
## OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
## Environment
|
||||
.env
|
||||
13
backend/ControlCenter.Api.csproj
Normal file
13
backend/ControlCenter.Api.csproj
Normal file
@@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.14" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
52
backend/Hubs/AgentStatusHub.cs
Normal file
52
backend/Hubs/AgentStatusHub.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
|
||||
namespace ControlCenter.Api.Hubs;
|
||||
|
||||
/// <summary>
|
||||
/// SignalR hub for broadcasting agent status updates to connected clients.
|
||||
///
|
||||
/// <para>
|
||||
/// Clients connect to this hub at the <c>/hub</c> endpoint to receive
|
||||
/// real-time agent state changes. A background service subscribes to
|
||||
/// OpenClaw Gateway events and pushes them through this hub.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// Architecture note: This hub bridges OpenClaw Gateway events to SignalR clients.
|
||||
/// The full typed client interface and extension methods will be added in a
|
||||
/// subsequent task (CUB-55).
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public class AgentStatusHub : Hub
|
||||
{
|
||||
private readonly ILogger<AgentStatusHub> _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AgentStatusHub"/> class.
|
||||
/// </summary>
|
||||
/// <param name="logger">Logger for diagnostic output.</param>
|
||||
public AgentStatusHub(ILogger<AgentStatusHub> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides <see cref="Hub.OnConnectedAsync"/> to log new connections.
|
||||
/// </summary>
|
||||
public override Task OnConnectedAsync()
|
||||
{
|
||||
_logger.LogDebug("Client connected: {ConnectionId}", Context.ConnectionId);
|
||||
return base.OnConnectedAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides <see cref="Hub.OnDisconnectedAsync"/> to log disconnections.
|
||||
/// SignalR automatically removes disconnected connections from all groups.
|
||||
/// </summary>
|
||||
/// <param name="exception">Exception that caused the disconnection, if any.</param>
|
||||
public override Task OnDisconnectedAsync(Exception? exception)
|
||||
{
|
||||
_logger.LogDebug("Client disconnected: {ConnectionId}", Context.ConnectionId);
|
||||
return base.OnDisconnectedAsync(exception);
|
||||
}
|
||||
}
|
||||
24
backend/Program.cs
Normal file
24
backend/Program.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using ControlCenter.Api.Hubs;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddOpenApi();
|
||||
|
||||
// Register SignalR for real-time agent status updates
|
||||
builder.Services.AddSignalR();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.MapOpenApi();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
// Map SignalR hub endpoint
|
||||
app.MapHub<AgentStatusHub>("/hub");
|
||||
|
||||
app.Run();
|
||||
23
backend/Properties/launchSettings.json
Normal file
23
backend/Properties/launchSettings.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "http://localhost:5178",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "https://localhost:7041;http://localhost:5178",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
8
backend/appsettings.Development.json
Normal file
8
backend/appsettings.Development.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
9
backend/appsettings.json
Normal file
9
backend/appsettings.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
Reference in New Issue
Block a user