[ADDITION] tried to fix the async methods.

This commit is contained in:
Dogukan
2020-10-22 16:11:19 +02:00
parent 5b5d66c41b
commit 3b667b3f0c
4 changed files with 39 additions and 14 deletions

View File

@@ -48,6 +48,9 @@ namespace Client
private void OnReadComplete(IAsyncResult ar)
{
if (ar == null || (!ar.IsCompleted) || (!this.stream.CanRead) || !this.tcpClient.Client.Connected)
return;
int amountReceived = stream.EndRead(ar);
if (totalBufferReceived + amountReceived > 1024)
@@ -140,6 +143,9 @@ namespace Client
case JSONConvert.RANDOMWORD:
//Flag byte for receiving the random word.
int lobbyId = JSONConvert.GetLobbyID(payload);
if(data.Lobby?.ID == lobbyId)
ViewModels.ViewModelGame.HandleRandomWord(JSONConvert.GetRandomWord(payload));
break;
default: