[TRY] tried to bind the label data, doesn't work yet
This commit is contained in:
@@ -179,9 +179,10 @@ namespace Client
|
|||||||
case JSONConvert.RANDOMWORD:
|
case JSONConvert.RANDOMWORD:
|
||||||
//Flag byte for receiving the random word.
|
//Flag byte for receiving the random word.
|
||||||
int lobbyId = JSONConvert.GetLobbyID(payload);
|
int lobbyId = JSONConvert.GetLobbyID(payload);
|
||||||
|
string randomWord = JSONConvert.GetRandomWord(payload);
|
||||||
|
|
||||||
if(data.Lobby?.ID == lobbyId)
|
if (data.Lobby?.ID == lobbyId)
|
||||||
ViewModels.ViewModelGame.HandleRandomWord(JSONConvert.GetRandomWord(payload));
|
ViewModels.ViewModelGame.HandleRandomWord(randomWord);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Debug.WriteLine("[CLIENT] Received weird identifier: " + id);
|
Debug.WriteLine("[CLIENT] Received weird identifier: " + id);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
using Client.Views;
|
using Client.Views;
|
||||||
|
using GalaSoft.MvvmLight;
|
||||||
using GalaSoft.MvvmLight.Command;
|
using GalaSoft.MvvmLight.Command;
|
||||||
using SharedClientServer;
|
using SharedClientServer;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -24,19 +25,17 @@ namespace Client.ViewModels
|
|||||||
private Color color;
|
private Color color;
|
||||||
|
|
||||||
public static ObservableCollection<string> Messages { get; } = new ObservableCollection<string>();
|
public static ObservableCollection<string> Messages { get; } = new ObservableCollection<string>();
|
||||||
|
|
||||||
public static ObservableCollection<string> Players { get; } = new ObservableCollection<string>();
|
public static ObservableCollection<string> Players { get; } = new ObservableCollection<string>();
|
||||||
|
|
||||||
private dynamic _payload;
|
private dynamic _payload;
|
||||||
|
|
||||||
public static string Word
|
private static string _randomWord;
|
||||||
|
public string RandomWord
|
||||||
{
|
{
|
||||||
get;
|
get { return _randomWord; }
|
||||||
set;
|
set { _randomWord = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string _username;
|
|
||||||
|
|
||||||
public string _message;
|
public string _message;
|
||||||
public string Message
|
public string Message
|
||||||
{
|
{
|
||||||
@@ -107,13 +106,13 @@ namespace Client.ViewModels
|
|||||||
Message = string.Empty;
|
Message = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void AddMessage(string message)
|
internal void AddMessage(string incomingMessage)
|
||||||
{
|
{
|
||||||
Messages.Add($"{data.User.Username}: {message}");
|
Messages.Add($"{data.User.Username}: {incomingMessage}");
|
||||||
_payload = new
|
_payload = new
|
||||||
{
|
{
|
||||||
username = data.User.Username,
|
username = data.User.Username,
|
||||||
message = message
|
message = incomingMessage
|
||||||
};
|
};
|
||||||
|
|
||||||
//Broadcast the message after adding it to the list!
|
//Broadcast the message after adding it to the list!
|
||||||
@@ -147,11 +146,8 @@ namespace Client.ViewModels
|
|||||||
*/
|
*/
|
||||||
public static void HandleRandomWord(string randomWord)
|
public static void HandleRandomWord(string randomWord)
|
||||||
{
|
{
|
||||||
Debug.WriteLine("[CLIENT] Reached the handle random word method!");
|
_randomWord = randomWord;
|
||||||
Application.Current.Dispatcher.Invoke(delegate
|
Debug.WriteLine($"[CLIENT] The random word is: {_randomWord}");
|
||||||
{
|
|
||||||
Word = randomWord;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void HandleIncomingPlayer(Lobby lobby)
|
public static void HandleIncomingPlayer(Lobby lobby)
|
||||||
|
|||||||
Reference in New Issue
Block a user