From 3fa0455f1b8824467886619af293c1bac7f93c3f Mon Sep 17 00:00:00 2001 From: Jonas Date: Sun, 22 Feb 2026 19:17:18 +0100 Subject: [PATCH] Add GameController with SignalR functionality for joining games --- .gitignore | 5 ++++- .idea/.idea.4Gewinnt/.idea/workspace.xml | 21 +++++++++++++++++---- API/API.csproj | 6 ++++++ API/Controllers/GameController.cs | 16 ++++++++++++++++ 4 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 API/Controllers/GameController.cs diff --git a/.gitignore b/.gitignore index 9491a2f..5dcad6f 100644 --- a/.gitignore +++ b/.gitignore @@ -360,4 +360,7 @@ MigrationBackup/ .ionide/ # Fody - auto-generated XML schema -FodyWeavers.xsd \ No newline at end of file +FodyWeavers.xsd + +# ai +.claude \ No newline at end of file diff --git a/.idea/.idea.4Gewinnt/.idea/workspace.xml b/.idea/.idea.4Gewinnt/.idea/workspace.xml index bba1e5e..b8d815e 100644 --- a/.idea/.idea.4Gewinnt/.idea/workspace.xml +++ b/.idea/.idea.4Gewinnt/.idea/workspace.xml @@ -9,10 +9,9 @@ - + + - - + + + @@ -146,6 +157,8 @@ diff --git a/API/API.csproj b/API/API.csproj index b7f4cae..7330b1b 100644 --- a/API/API.csproj +++ b/API/API.csproj @@ -11,4 +11,10 @@ + + + + + + diff --git a/API/Controllers/GameController.cs b/API/Controllers/GameController.cs new file mode 100644 index 0000000..971d3e4 --- /dev/null +++ b/API/Controllers/GameController.cs @@ -0,0 +1,16 @@ +using Microsoft.AspNetCore.SignalR; + +namespace API.Controllers; + +public class GameController : Hub +{ + public async Task JoinGame(string gameId, string playerName) + { + await Groups.AddToGroupAsync(Context.ConnectionId, gameId); + await Clients.Group(gameId).SendAsync("PlayerJoined", new + { + ConnectionId = Context.ConnectionId, + PlayerName = playerName + }); + } +} \ No newline at end of file