diff --git a/DoctorApp/Utils/Client.cs b/DoctorApp/Utils/Client.cs index f5fa102..15669b6 100644 --- a/DoctorApp/Utils/Client.cs +++ b/DoctorApp/Utils/Client.cs @@ -111,10 +111,10 @@ namespace DoctorApp.Utils Console.WriteLine("Set resistance identifier"); break; case DataParser.NEW_CONNECTION: - this.MainViewModel.NewConnectedUser(DataParser.getUsernameFromResponseJson(payloadbytes)); + this.MainViewModel.NewConnectedUser(DataParser.getUsernameFromJson(payloadbytes)); break; case DataParser.DISCONNECT: - this.MainViewModel.DisconnectedUser(DataParser.getUsernameFromResponseJson(payloadbytes)); + this.MainViewModel.DisconnectedUser(DataParser.getUsernameFromJson(payloadbytes)); break; default: Console.WriteLine($"Received json with identifier {identifier}:\n{Encoding.ASCII.GetString(payloadbytes)}"); diff --git a/DoctorApp/Views/MainView.xaml b/DoctorApp/Views/MainView.xaml index dc14aee..80cf8c9 100644 --- a/DoctorApp/Views/MainView.xaml +++ b/DoctorApp/Views/MainView.xaml @@ -11,7 +11,7 @@ - + diff --git a/Server/Client.cs b/Server/Client.cs index 74425ef..7a89f5f 100644 --- a/Server/Client.cs +++ b/Server/Client.cs @@ -65,6 +65,8 @@ namespace Server } } + if (ar == null || (!ar.IsCompleted) || (!this.stream.CanRead)) + return; this.stream.BeginRead(this.buffer, 0, this.buffer.Length, new AsyncCallback(OnRead), null); }