[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

@@ -1,11 +1,12 @@
using Client.Views;
using Client.Views;
using GalaSoft.MvvmLight.Command;
using SharedClientServer;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
@@ -25,6 +26,12 @@ namespace Client.ViewModels
private dynamic _payload;
public static string Word
{
get;
set;
}
public string _username;
public string _message;
@@ -82,21 +89,10 @@ namespace Client.ViewModels
colorSelected.B = window.ClrPcker_Background.SelectedColor.Value.B;
color = colorSelected;
}
public ViewModelGame()
{
if (_payload == null)
{
_message = "";
}
else
{
//_message = data.Message;
//_username = data.User.Username;
//Messages.Add($"{data.User.Username}: {Message}");
}
OnKeyDown = new RelayCommand(ChatBox_KeyDown);
}
@@ -121,6 +117,10 @@ namespace Client.ViewModels
data.Client.SendMessage(JSONConvert.GetMessageToSend(JSONConvert.MESSAGE, _payload));
}
/*
* MISC make this a callback
* Handles the incoming chat message from another client.
*/
public static void HandleIncomingMsg(string username, string message)
{
Application.Current.Dispatcher.Invoke(delegate
@@ -128,13 +128,21 @@ namespace Client.ViewModels
Messages.Add($"{username}: {message}");
});
}
public void LeaveGame(object sender, System.ComponentModel.CancelEventArgs e)
public void LeaveGame(object sender, CancelEventArgs e)
{
Debug.WriteLine("Leaving...");
data.Client.SendMessage(JSONConvert.ConstructLobbyLeaveMessage(data.Lobby.ID));
}
/*
* MISC make this a callback
* Handles the random word that has been received from the server.
*/
public static void HandleRandomWord(string randomWord)
{
Debug.WriteLine("[CLIENT] Reached the handle random word method!");
Word = "NegerPik";
}
}
}