Develop #10

Merged
SemvdH merged 229 commits from develop into master 2020-10-29 22:50:49 +00:00
3 changed files with 26 additions and 1 deletions
Showing only changes of commit 6a9e2b57ac - Show all commits

View File

@@ -167,6 +167,12 @@ namespace ClientApp.Utils
engineConnection.DoctorMessage = DataParser.getChatMessageFromJson(payloadbytes);
Debug.WriteLine("received message from doctor");
break;
case DataParser.NEW_CONNECTION:
this.LoginViewModel.DoctorConnected(DataParser.getUsernameFromJson(payloadbytes));
break;
case DataParser.DISCONNECT:
this.LoginViewModel.DoctorDisconnected(DataParser.getUsernameFromJson(payloadbytes));
break;
default:
Console.WriteLine($"Received json with identifier {identifier}:\n{Encoding.ASCII.GetString(payloadbytes)}");
break;

View File

@@ -42,5 +42,15 @@ namespace ClientApp.ViewModels
this.MainWindowViewModel.SelectedViewModel = new MainViewModel(MainWindowViewModel);
}
}
internal void DoctorConnected(string name)
{
this.MainWindowViewModel.InfoModel.DoctorConnected = true;
}
internal void DoctorDisconnected(string name)
{
this.MainWindowViewModel.InfoModel.DoctorConnected = false;
}
}
}

View File

@@ -22,6 +22,7 @@ namespace Server
this.clients.ForEach((client) =>
{
this.mDoctor.sendMessage(DataParser.getNewConnectionJson(client.username));
client.sendMessage(DataParser.getNewConnectionJson(this.mDoctor.username));
});
}
}
@@ -58,13 +59,21 @@ namespace Server
public void NewLogin(Client client)
{
this.clients.Add(client);
Doctor?.sendMessage(DataParser.getNewConnectionJson(client.username));
if (this.Doctor != null)
{
Doctor.sendMessage(DataParser.getNewConnectionJson(client.username));
client.sendMessage(DataParser.getNewConnectionJson(Doctor.username));
}
}
public void LogOff(Client client)
{
if (this.Doctor == client)
{
this.clients.ForEach((client) =>
{
client.sendMessage(DataParser.getDisconnectJson(this.mDoctor.username));
});
this.Doctor = null;
}
this.clients.Remove(client);