RT server and signalr

This commit is contained in:
2026-02-15 20:33:08 +01:00
parent 6d8ae9bef6
commit cc47ac3a59
13 changed files with 214 additions and 1 deletions

View File

@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,11 @@
using Microsoft.AspNetCore.SignalR;
namespace AipsRT.Hubs;
public class TestHub : Hub
{
public async Task SendText(string text)
{
await Clients.All.SendAsync("ReceiveText", text);
}
}

31
dotnet/AipsRT/Program.cs Normal file
View File

@@ -0,0 +1,31 @@
using AipsRT.Hubs;
using Microsoft.AspNetCore.SignalR;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSignalR();
builder.Services.AddCors(options =>
{
options.AddPolicy("frontend",
policy =>
{
policy
.WithOrigins("http://localhost:5173")
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
var app = builder.Build();
app.MapGet("/test", (IHubContext<TestHub> hubContext) =>
{
hubContext.Clients.All.SendAsync("ReceiveText", "Ide gas! ");
});
app.UseCors("frontend");
app.MapHub<TestHub>("/testhub");
app.Run();

View File

@@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5039",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7287;http://localhost:5039",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}