Skip to content

Commit

Permalink
New check for server disconnect
Browse files Browse the repository at this point in the history
A kill byte isn't received anymore
  • Loading branch information
LumpBloom7 committed Sep 26, 2021
1 parent 491f56d commit 82c079d
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,20 +148,20 @@ private async void clientLoop()
{
TransmissionData packet = new TransmissionData(buffer[0]);

// Server has shut down
if (packet == TransmissionData.Kill)
{
// On non-Windows platforms, the client doesn't automatically reconnect
// So we must recreate the client to ensure safety;
pipeClient.Dispose();
pipeClient = new NamedPipeClientStream(".", "senPipe",
PipeDirection.In, PipeOptions.Asynchronous,
TokenImpersonationLevel.Impersonation);
}

if (packet != TransmissionData.Empty)
text.Text = packet.ToString();
}
else if (result == 0) // End of stream reached, meaning that the server disconnected
{
text.Text = TransmissionData.Kill.ToString();

// On non-Windows platforms, the client doesn't automatically reconnect
// So we must recreate the client to ensure safety;
pipeClient.Dispose();
pipeClient = new NamedPipeClientStream(".", "senPipe",
PipeDirection.In, PipeOptions.Asynchronous,
TokenImpersonationLevel.Impersonation);
}
}
catch
{
Expand Down

0 comments on commit 82c079d

Please sign in to comment.