From 7df48ab3227ad554f7e4529800d12408b790307b Mon Sep 17 00:00:00 2001 From: Dogukan Date: Fri, 23 Oct 2020 14:49:20 +0200 Subject: [PATCH] [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 @@ -