[ADDED] lobby now secured when the game starts. start button is still for everyone available, not working yet

This commit is contained in:
Lars
2020-10-22 15:40:09 +02:00
parent 8190724f77
commit cac0fdc0a4
10 changed files with 467 additions and 363 deletions

View File

@@ -134,8 +134,9 @@ namespace Server.Models
LobbyIdentifier l = JSONConvert.GetLobbyIdentifier(payload);
handleLobbyMessage(payload,l);
break;
case JSONConvert.CANVAS:
Debug.WriteLine("GOT A MESSAGE FROM THE CLIENT ABOUT THE CANVAS!!!");
Debug.WriteLine("[SERVERCLIENT] GOT A MESSAGE FROM THE CLIENT ABOUT THE CANVAS!!!");
dynamic canvasData = new {
coordinatesLine = JSONConvert.getCoordinates(payload)
};
@@ -143,7 +144,22 @@ namespace Server.Models
// canvas data
// todo send canvas data to all other serverclients in lobby
break;
case JSONConvert.GAME:
Debug.WriteLine("[SERVERCLIENT] Got a message about the game logic");
string command = JSONConvert.GetGameCommand(payload);
switch (command)
{
case "startGame":
int lobbyID = JSONConvert.GetStartGameLobbyID(payload);
serverCom.CloseALobby(lobbyID);
ServerCommunication.INSTANCE.sendToAll(JSONConvert.ConstructLobbyListMessage(ServerCommunication.INSTANCE.lobbies.ToArray()));
break;
}
break;
default:
Debug.WriteLine("[SERVER] Received weird identifier: " + id);
break;

View File

@@ -183,5 +183,16 @@ namespace Server.Models
}
}
}
public void CloseALobby(int lobbyID)
{
foreach (Lobby lobby in lobbies)
{
if (lobby.ID == lobbyID)
{
lobby.LobbyJoineble = false;
}
}
}
}
}