[FIX] Callbacks weren't properly called

This commit is contained in:
Dogukan
2020-10-23 14:49:20 +02:00
parent 80d970da35
commit 7df48ab322
3 changed files with 4 additions and 25 deletions

View File

@@ -94,7 +94,6 @@ namespace Client
throw new OutOfMemoryException("buffer too small"); throw new OutOfMemoryException("buffer too small");
} }
Array.Copy(buffer, 0, totalBuffer, totalBufferReceived, amountReceived); Array.Copy(buffer, 0, totalBuffer, totalBufferReceived, amountReceived);
totalBufferReceived += amountReceived; totalBufferReceived += amountReceived;

View File

@@ -48,19 +48,12 @@ namespace Client.ViewModels
} }
private string _randomWord; private string _randomWord;
public string RandomWord public string RandomWord
{ {
get { return _randomWord; } get { return _randomWord; }
set { _randomWord = value; } set { _randomWord = value; }
} }
public static string Word
{
get;
set;
}
public bool IsHost public bool IsHost
{ {
get { return data.User.Host; } get { return data.User.Host; }
@@ -69,17 +62,6 @@ namespace Client.ViewModels
public ViewModelGame(GameWindow window) public ViewModelGame(GameWindow window)
{ {
this.window = 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][]; buffer = new double[maxLines][];
linesQueue = new Queue<double[][]>(); linesQueue = new Queue<double[][]>();
@@ -228,7 +210,7 @@ namespace Client.ViewModels
data.Client.SendMessage(JSONConvert.GetMessageToSend(JSONConvert.MESSAGE, _payload)); 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 Application.Current.Dispatcher.Invoke(delegate
{ {
@@ -241,12 +223,12 @@ namespace Client.ViewModels
data.Client.SendMessage(JSONConvert.ConstructLobbyLeaveMessage(data.Lobby.ID)); 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!"); Debug.WriteLine("[CLIENT] Reached the handle random word method!");
Application.Current.Dispatcher.Invoke(delegate Application.Current.Dispatcher.Invoke(delegate
{ {
Word = randomWord; RandomWord = randomWord;
}); });
} }
public void HandleIncomingPlayer(Lobby lobby) public void HandleIncomingPlayer(Lobby lobby)

View File

@@ -38,10 +38,8 @@
<xctk:ColorPicker Name="ClrPcker_Background" SelectedColorChanged="ClrPcker_Background_SelectedColorChanged_1" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Height="22" Width="100"/> <xctk:ColorPicker Name="ClrPcker_Background" SelectedColorChanged="ClrPcker_Background_SelectedColorChanged_1" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Height="22" Width="100"/>
<Label Name="GuessWord" Grid.Row="0" Grid.Column="1" Content="{Binding Path=RandomWord, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" HorizontalAlignment="Center"/> <Label Name="GuessWord" Grid.Row="0" Grid.Column="2" Content="{Binding Path=RandomWord, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="20"/>
<Label Grid.Row="0" Grid.Column="2" FontSize="20" Content="" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Button Name="CanvasReset" Click="CanvasReset_Click" Grid.Row="0" Grid.Column="3" Content="RESET"/> <Button Name="CanvasReset" Click="CanvasReset_Click" Grid.Row="0" Grid.Column="3" Content="RESET"/>
</Grid> </Grid>