1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:27:45 +00:00

LibTLS: Use a setter for on_tls_ready_to_write with some more smarts

The callback should be called as soon as the connection is established,
and if we actually set the callback when it already is, we expect it to
be called immediately.
This commit is contained in:
Ali Mohammad Pur 2021-09-19 02:31:11 +04:30 committed by Ali Mohammad Pur
parent d3ea0818f3
commit 436693c0c9
6 changed files with 28 additions and 13 deletions

View file

@ -33,9 +33,10 @@ void TLSv12WebSocketConnectionImpl::connect(ConnectionInfo const& connection)
m_socket->on_tls_ready_to_read = [this](auto&) {
on_ready_to_read();
};
m_socket->on_tls_ready_to_write = [this](auto&) {
m_socket->set_on_tls_ready_to_write([this](auto& tls) {
tls.set_on_tls_ready_to_write(nullptr);
on_connected();
};
});
m_socket->on_tls_finished = [this] {
on_connection_error();
};