Add GameController with SignalR functionality for joining games

This commit is contained in:
2026-02-22 19:17:18 +01:00
committed by Jonas
parent f98d9e79b2
commit 3fa0455f1b
4 changed files with 43 additions and 5 deletions
+6
View File
@@ -11,4 +11,10 @@
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.2.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Models\" />
<Folder Include="Repository\" />
<Folder Include="Services\" />
</ItemGroup>
</Project>
+16
View File
@@ -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
});
}
}