[wpinet] WebSocket: When Close() is called, call closed immediately (#5047)

This provides the closed callback with the real reason for the
connection being closed.  Keep closed from being called twice by adding
a check in SetClosed().
This commit is contained in:
Peter Johnson
2023-02-03 22:59:19 -08:00
committed by GitHub
parent 49459d3e45
commit b879a6f8c6
2 changed files with 6 additions and 2 deletions

View File

@@ -125,13 +125,13 @@ TEST_F(WebSocketIntegrationTest, ClientSendText) {
++gotData;
ASSERT_EQ(data, "hello");
});
ws.closed.connect([&](auto code, auto reason) { Finish(); });
});
});
clientPipe->Connect(pipeName, [&] {
auto ws = WebSocket::CreateClient(*clientPipe, "/test", pipeName);
ws->closed.connect([&](uint16_t code, std::string_view reason) {
Finish();
if (code != 1005 && code != 1006) {
FAIL() << "Code: " << code << " Reason: " << reason;
}