Initial commit.

This commit is contained in:
2026-03-13 10:23:47 +01:00
parent fd81c63020
commit 39c8b861c0
44 changed files with 1144 additions and 4 deletions

View File

@@ -0,0 +1,41 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>ClientApiPoC.ApiService</RootNamespace>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>
<PublishTrimmed>false</PublishTrimmed>
<Company>Mike Schumann</Company>
<Copyright>Copyright © 2026 $(Company)</Copyright>
<AssemblyVersion>0.1.0</AssemblyVersion>
<FileVersion>$(AssemblyVersion)</FileVersion>
<NeutralLanguage>en-US</NeutralLanguage>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DebugType>portable</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.5" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="10.1.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Shared\Shared.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,27 @@
using ClientApiPoC.Shared;
using ClientApiPoC.Shared.Models;
using Microsoft.AspNetCore.Mvc;
namespace ClientApiPoC.ApiService.Controllers {
[ApiController]
[Route(Routes.EXAMPLE_REQUEST)]
public class ExampleRequestController : ControllerBase {
private readonly TunnelServer _tunnel;
public ExampleRequestController(TunnelServer tunnel) {
if (tunnel == null) throw new ArgumentNullException(nameof(tunnel));
_tunnel = tunnel;
}
[HttpGet]
public async Task<ExampleRequestResultModel> Get() {
// Daten der Clients abfragen...
var clients = await _tunnel.GetDataFromAllClientsAsync();
var result = new ExampleRequestResultModel() {
ServerMessage = "Hello, world!",
Clients = clients
};
return result;
}
}
}

34
ApiService/Program.cs Normal file
View File

@@ -0,0 +1,34 @@
using ClientApiPoC.Shared;
using ClientApiPoC.Shared.SignalR;
namespace ClientApiPoC.ApiService {
public class Program {
public static void Main(string[] args) {
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddOpenApi();
builder.Services.AddTunnelHub();
builder.Services.AddTransient<TunnelServer>();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment()) {
app.MapOpenApi();
app.UseSwaggerUI(options => {
options.SwaggerEndpoint("/openapi/v1.json", "ClientApiPoC");
});
}
app.UseAuthorization();
app.MapControllers();
app.MapTunnelHub(Routes.TUNNEL_PATH);
app.Run();
}
}
}

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
<Project>
<PropertyGroup>
<DeleteExistingFiles>true</DeleteExistingFiles>
<ExcludeApp_Data>false</ExcludeApp_Data>
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>..\Publish\ApiService\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<_TargetId>Folder</_TargetId>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>net10.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<ProjectGuid>bb6e670a-3d3d-430e-4dd4-25ad2c7d9c26</ProjectGuid>
<SelfContained>true</SelfContained>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,14 @@
{
"profiles": {
"http": {
"commandName": "Project",
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://*:5228"
}
},
"$schema": "https://json.schemastore.org/launchsettings.json"
}

View File

@@ -0,0 +1,24 @@
using Microsoft.AspNetCore.SignalR;
using ClientApiPoC.Shared.SignalR;
using ClientApiPoC.Shared.Models;
namespace ClientApiPoC.ApiService {
public class TunnelServer : TunnelServerBase {
public TunnelServer(IHubContext<TunnelHub> hubContext, ClientTracker clientTracker) : base(hubContext, clientTracker) { }
public async Task<IEnumerable<ClientResultModel>> GetDataFromAllClientsAsync() {
var timestampServer = DateTime.UtcNow;
var results = new List<ClientResultModel>();
var clients = this.GetAllClients();
foreach (var client in clients) {
var clientData = await client.Value.InvokeAsync<ClientDataModel>("GetClientData", timestampServer, CancellationToken.None);
var result = new ClientResultModel() {
ClientId = client.Key,
ClientData = clientData
};
results.Add(result);
}
return results;
}
}
}

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@@ -0,0 +1,16 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://*:5228"
}
}
}
}

View File

@@ -0,0 +1,13 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "10.0.5",
"commands": [
"dotnet-ef"
],
"rollForward": false
}
}
}