RT server and signalr
This commit is contained in:
9
dotnet/AipsRT/AipsRT.csproj
Normal file
9
dotnet/AipsRT/AipsRT.csproj
Normal file
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
11
dotnet/AipsRT/Hubs/TestHub.cs
Normal file
11
dotnet/AipsRT/Hubs/TestHub.cs
Normal 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
31
dotnet/AipsRT/Program.cs
Normal 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();
|
||||
23
dotnet/AipsRT/Properties/launchSettings.json
Normal file
23
dotnet/AipsRT/Properties/launchSettings.json
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AipsWebApi", "AipsWebApi\Ai
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AipsWorker", "AipsWorker\AipsWorker.csproj", "{8BEF3002-13ED-47E4-9A54-A0EF0B36CC1E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AipsRT", "AipsRT\AipsRT.csproj", "{ECC5AA68-E53A-48E9-965A-E0BCBCE403D5}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -26,5 +28,9 @@ Global
|
||||
{8BEF3002-13ED-47E4-9A54-A0EF0B36CC1E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8BEF3002-13ED-47E4-9A54-A0EF0B36CC1E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8BEF3002-13ED-47E4-9A54-A0EF0B36CC1E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{ECC5AA68-E53A-48E9-965A-E0BCBCE403D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{ECC5AA68-E53A-48E9-965A-E0BCBCE403D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{ECC5AA68-E53A-48E9-965A-E0BCBCE403D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{ECC5AA68-E53A-48E9-965A-E0BCBCE403D5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
Reference in New Issue
Block a user