From 705a6cedb23c275d9ee0fde18bb86bf3454dc0a8 Mon Sep 17 00:00:00 2001 From: DTieman Date: Mon, 24 Apr 2023 13:59:38 +0200 Subject: [PATCH] removed auth and fixed id bug --- Controllers/AuthController.cs | 15 --------------- Mau/GameState.cs | 2 +- Room/Room.cs | 14 +++----------- 3 files changed, 4 insertions(+), 27 deletions(-) delete mode 100644 Controllers/AuthController.cs diff --git a/Controllers/AuthController.cs b/Controllers/AuthController.cs deleted file mode 100644 index 4333a0a..0000000 --- a/Controllers/AuthController.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Text.Json; -using Microsoft.AspNetCore.Mvc; - -namespace MauMau_Server.Controllers; - -[ApiController] -[Route("[controller]")] -public class AuthController : ControllerBase -{ - [HttpGet] - public async Task Get() - { - return Ok(JsonSerializer.Serialize(Guid.NewGuid())); - } -} \ No newline at end of file diff --git a/Mau/GameState.cs b/Mau/GameState.cs index 7186c5c..5f510c1 100644 --- a/Mau/GameState.cs +++ b/Mau/GameState.cs @@ -19,7 +19,7 @@ public class GameState foreach (var player in game.Players) { - Players.Add(p.Connection.ConnectionId); + Players.Add(player.Connection.ConnectionId); } CurrentCard = game.CurrentCard.ToString(); diff --git a/Room/Room.cs b/Room/Room.cs index 44aac62..b89e655 100644 --- a/Room/Room.cs +++ b/Room/Room.cs @@ -1,6 +1,4 @@ -using System.Collections; -using System.Net.WebSockets; -using System.Text; +using System.Net.WebSockets; using System.Text.Json; using MauMau_Server.Mau; @@ -62,13 +60,12 @@ public class Room private ConnectionInstance AddConnection(WebSocket socket) { var connectionId = Guid.NewGuid().ToString(); - // TODO: Why does every connection have the same connectionId? var connection = new ConnectionInstance(connectionId, socket); _connections.Add(connection); return connection; } - public void RemoveConnection(string socketId) + private void RemoveConnection(string socketId) { _connections.RemoveAll(connection => connection.ConnectionId == socketId); } @@ -102,12 +99,7 @@ public class Room return _connections.Select(connection => connection.Socket).ToList(); } - private static byte[] EmptyBuffer() - { - return new byte[4096]; - } - - public bool IsEmpty() + private bool IsEmpty() { return _connections.Count == 0; }