Merge branch 'develop' of https://github.com/SemvdH/Proftaak-RH-B4 into develop
This commit is contained in:
@@ -21,13 +21,13 @@
|
|||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="Images\Icons\CheckMark.png">
|
<Content Include="Images\Icons\CheckMark.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="Images\Icons\CrossMark.png">
|
<Content Include="Images\Icons\CrossMark.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="Images\Logo\icon1.ico">
|
<Content Include="Images\Logo\icon1.ico">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="Images\re15.jpg">
|
<Content Include="Images\re15.jpg">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
|||||||
@@ -130,6 +130,8 @@ namespace DoctorApp.Utils
|
|||||||
expectedMessageLength = BitConverter.ToInt32(totalBuffer, 0);
|
expectedMessageLength = BitConverter.ToInt32(totalBuffer, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ar == null || (!ar.IsCompleted) || (!this.stream.CanRead) || !this.client.Connected)
|
||||||
|
return;
|
||||||
this.stream.BeginRead(this.buffer, 0, this.buffer.Length, new AsyncCallback(OnRead), null);
|
this.stream.BeginRead(this.buffer, 0, this.buffer.Length, new AsyncCallback(OnRead), null);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -192,6 +194,7 @@ namespace DoctorApp.Utils
|
|||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Debug.WriteLine("client dispose called");
|
Debug.WriteLine("client dispose called");
|
||||||
|
sendMessage(DataParser.getDisconnectJson(LoginViewModel.Username));
|
||||||
this.stream.Dispose();
|
this.stream.Dispose();
|
||||||
this.client.Dispose();
|
this.client.Dispose();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace Server
|
|||||||
|
|
||||||
private void OnRead(IAsyncResult ar)
|
private void OnRead(IAsyncResult ar)
|
||||||
{
|
{
|
||||||
if (ar == null || (!ar.IsCompleted) || (!this.stream.CanRead))
|
if (ar == null || (!ar.IsCompleted) || (!this.stream.CanRead) || !this.tcpClient.Client.Connected)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int receivedBytes = this.stream.EndRead(ar);
|
int receivedBytes = this.stream.EndRead(ar);
|
||||||
@@ -65,7 +65,7 @@ namespace Server
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ar == null || (!ar.IsCompleted) || (!this.stream.CanRead))
|
if (ar == null || (!ar.IsCompleted) || (!this.stream.CanRead) || !this.tcpClient.Client.Connected)
|
||||||
return;
|
return;
|
||||||
this.stream.BeginRead(this.buffer, 0, this.buffer.Length, new AsyncCallback(OnRead), null);
|
this.stream.BeginRead(this.buffer, 0, this.buffer.Length, new AsyncCallback(OnRead), null);
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ namespace Server
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case DataParser.DISCONNECT:
|
case DataParser.DISCONNECT:
|
||||||
communication.Disconnect(this);
|
communication.LogOff(this);
|
||||||
break;
|
break;
|
||||||
case DataParser.MESSAGE:
|
case DataParser.MESSAGE:
|
||||||
communication.SendMessageToClient(DataParser.getUsernameFromJson(payloadbytes), message);
|
communication.SendMessageToClient(DataParser.getUsernameFromJson(payloadbytes), message);
|
||||||
|
|||||||
@@ -19,11 +19,12 @@ namespace Server
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
this.mDoctor = value;
|
this.mDoctor = value;
|
||||||
this.clients.ForEach((client) =>
|
if (this.mDoctor != null)
|
||||||
{
|
this.clients.ForEach((client) =>
|
||||||
this.mDoctor.sendMessage(DataParser.getNewConnectionJson(client.username));
|
{
|
||||||
client.sendMessage(DataParser.getNewConnectionJson(this.mDoctor.username));
|
this.mDoctor.sendMessage(DataParser.getNewConnectionJson(client.username));
|
||||||
});
|
client.sendMessage(DataParser.getNewConnectionJson(this.mDoctor.username));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public Communication(TcpListener listener)
|
public Communication(TcpListener listener)
|
||||||
@@ -50,12 +51,6 @@ namespace Server
|
|||||||
listener.BeginAcceptTcpClient(new AsyncCallback(OnConnect), null);
|
listener.BeginAcceptTcpClient(new AsyncCallback(OnConnect), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Disconnect(Client client)
|
|
||||||
{
|
|
||||||
clients.Remove(client);
|
|
||||||
Doctor.sendMessage(DataParser.getDisconnectJson(client.username));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void NewLogin(Client client)
|
public void NewLogin(Client client)
|
||||||
{
|
{
|
||||||
this.clients.Add(client);
|
this.clients.Add(client);
|
||||||
@@ -76,6 +71,7 @@ namespace Server
|
|||||||
});
|
});
|
||||||
this.Doctor = null;
|
this.Doctor = null;
|
||||||
}
|
}
|
||||||
|
Doctor?.sendMessage(DataParser.getDisconnectJson(client.username));
|
||||||
this.clients.Remove(client);
|
this.clients.Remove(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user