From 6512518fb72c6c15829ce2b6052062a5cac2a4ce Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Fri, 23 Oct 2020 14:30:16 +0200 Subject: [PATCH 1/3] [FIX] made first user in lobby a host if the host leaves --- Server/Models/ServerCommunication.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Server/Models/ServerCommunication.cs b/Server/Models/ServerCommunication.cs index e55c835..e70d376 100644 --- a/Server/Models/ServerCommunication.cs +++ b/Server/Models/ServerCommunication.cs @@ -142,7 +142,7 @@ namespace Server.Models { foreach (ServerClient sc in serverClientsInlobbies[l]) { - Debug.WriteLine("[SERVERCLIENT] Sending message"); + Debug.WriteLine("[SERVERCLIENT] Sending message to lobby"); sc.sendMessage(message); } break; @@ -261,6 +261,10 @@ namespace Server.Models break; } } + if (l.Users.Count != 0) + { + l.Users[0].Host = true; + } break; } } -- 2.47.2 From 7df48ab3227ad554f7e4529800d12408b790307b Mon Sep 17 00:00:00 2001 From: Dogukan Date: Fri, 23 Oct 2020 14:49:20 +0200 Subject: [PATCH 2/3] [FIX] Callbacks weren't properly called --- Client/Client.cs | 1 - Client/ViewModels/ViewModelGame.cs | 24 +++--------------------- Client/Views/GameWindow.xaml | 4 +--- 3 files changed, 4 insertions(+), 25 deletions(-) diff --git a/Client/Client.cs b/Client/Client.cs index d3788f3..c33d66b 100644 --- a/Client/Client.cs +++ b/Client/Client.cs @@ -94,7 +94,6 @@ namespace Client throw new OutOfMemoryException("buffer too small"); } - Array.Copy(buffer, 0, totalBuffer, totalBufferReceived, amountReceived); totalBufferReceived += amountReceived; diff --git a/Client/ViewModels/ViewModelGame.cs b/Client/ViewModels/ViewModelGame.cs index 40ac402..2f6e03e 100644 --- a/Client/ViewModels/ViewModelGame.cs +++ b/Client/ViewModels/ViewModelGame.cs @@ -48,19 +48,12 @@ namespace Client.ViewModels } private string _randomWord; - public string RandomWord { get { return _randomWord; } set { _randomWord = value; } } - public static string Word - { - get; - set; - } - public bool IsHost { get { return data.User.Host; } @@ -69,17 +62,6 @@ namespace Client.ViewModels public ViewModelGame(GameWindow window) { this.window = window; - if (_payload == null) - { - _message = ""; - - } - else - { - //_message = data.Message; - //_username = data.User.Username; - //Messages.Add($"{data.User.Username}: {Message}"); - } buffer = new double[maxLines][]; linesQueue = new Queue(); @@ -228,7 +210,7 @@ namespace Client.ViewModels data.Client.SendMessage(JSONConvert.GetMessageToSend(JSONConvert.MESSAGE, _payload)); } - public static void HandleIncomingMsg(string username, string message) + public void HandleIncomingMsg(string username, string message) { Application.Current.Dispatcher.Invoke(delegate { @@ -241,12 +223,12 @@ namespace Client.ViewModels data.Client.SendMessage(JSONConvert.ConstructLobbyLeaveMessage(data.Lobby.ID)); } - public static void HandleRandomWord(string randomWord) + public void HandleRandomWord(string randomWord) { Debug.WriteLine("[CLIENT] Reached the handle random word method!"); Application.Current.Dispatcher.Invoke(delegate { - Word = randomWord; + RandomWord = randomWord; }); } public void HandleIncomingPlayer(Lobby lobby) diff --git a/Client/Views/GameWindow.xaml b/Client/Views/GameWindow.xaml index dde8efc..eaf5391 100644 --- a/Client/Views/GameWindow.xaml +++ b/Client/Views/GameWindow.xaml @@ -38,10 +38,8 @@ -