[ADDITION] Tried to send the random word to a lobby

This commit is contained in:
Dogukan
2020-10-22 13:55:19 +02:00
parent ef255e4828
commit 5b5d66c41b
7 changed files with 66 additions and 24 deletions

View File

@@ -152,6 +152,10 @@ namespace Server.Models
// canvas data
// todo send canvas data to all other serverclients in lobby
break;
case JSONConvert.RANDOMWORD:
//Flag byte for receiving the random word.
break;
default:
Debug.WriteLine("[SERVER] Received weird identifier: " + id);
break;
@@ -177,8 +181,13 @@ namespace Server.Models
int id = JSONConvert.GetLobbyID(payload);
ServerCommunication.INSTANCE.JoinLobby(this.User,id);
sendMessage(JSONConvert.ConstructLobbyJoinSuccessMessage());
serverCom.SendToLobby(serverCom.GetLobbyForUser(User), JSONConvert.GetMessageToSend(RANDOMWORD, new
{
word = JSONConvert.SendRandomWord("WordsForGame.json")
}));
ServerCommunication.INSTANCE.sendToAll(JSONConvert.ConstructLobbyListMessage(ServerCommunication.INSTANCE.lobbies.ToArray()));
Debug.WriteLine("Random chosen word: {0}", JSONConvert.GetRandomWord(@"..\resources\WordsForGame.json"));
break;
case LobbyIdentifier.LEAVE:
id = JSONConvert.GetLobbyID(payload);

View File

@@ -142,6 +142,7 @@ namespace Server.Models
{
foreach (ServerClient sc in serverClientsInlobbies[l])
{
Debug.WriteLine("[SERVERCLIENT] Sending message");
sc.sendMessage(message);
}
break;

View File

@@ -12,7 +12,7 @@
<ItemGroup>
<Content Include="resources\WordsForGame.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>