Develop #10
@@ -167,6 +167,12 @@ namespace ClientApp.Utils
|
|||||||
engineConnection.DoctorMessage = DataParser.getChatMessageFromJson(payloadbytes);
|
engineConnection.DoctorMessage = DataParser.getChatMessageFromJson(payloadbytes);
|
||||||
Debug.WriteLine("received message from doctor");
|
Debug.WriteLine("received message from doctor");
|
||||||
break;
|
break;
|
||||||
|
case DataParser.NEW_CONNECTION:
|
||||||
|
this.LoginViewModel.DoctorConnected(DataParser.getUsernameFromJson(payloadbytes));
|
||||||
|
break;
|
||||||
|
case DataParser.DISCONNECT:
|
||||||
|
this.LoginViewModel.DoctorDisconnected(DataParser.getUsernameFromJson(payloadbytes));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Console.WriteLine($"Received json with identifier {identifier}:\n{Encoding.ASCII.GetString(payloadbytes)}");
|
Console.WriteLine($"Received json with identifier {identifier}:\n{Encoding.ASCII.GetString(payloadbytes)}");
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -42,5 +42,15 @@ namespace ClientApp.ViewModels
|
|||||||
this.MainWindowViewModel.SelectedViewModel = new MainViewModel(MainWindowViewModel);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ namespace Server
|
|||||||
this.clients.ForEach((client) =>
|
this.clients.ForEach((client) =>
|
||||||
{
|
{
|
||||||
this.mDoctor.sendMessage(DataParser.getNewConnectionJson(client.username));
|
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)
|
public void NewLogin(Client client)
|
||||||
{
|
{
|
||||||
this.clients.Add(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)
|
public void LogOff(Client client)
|
||||||
{
|
{
|
||||||
if (this.Doctor == client)
|
if (this.Doctor == client)
|
||||||
{
|
{
|
||||||
|
this.clients.ForEach((client) =>
|
||||||
|
{
|
||||||
|
client.sendMessage(DataParser.getDisconnectJson(this.mDoctor.username));
|
||||||
|
});
|
||||||
this.Doctor = null;
|
this.Doctor = null;
|
||||||
}
|
}
|
||||||
this.clients.Remove(client);
|
this.clients.Remove(client);
|
||||||
|
|||||||
Reference in New Issue
Block a user