diff options
author | eidheim <eidheim@gmail.com> | 2021-04-28 11:19:19 +0300 |
---|---|---|
committer | eidheim <eidheim@gmail.com> | 2021-04-28 11:19:19 +0300 |
commit | 298c66c9afb719d22fbc14c5171a45d571ba9309 (patch) | |
tree | 16747575e385ddef938e2559194728e15403e6f7 | |
parent | 8a687be02c0fc13cb165e3e83b8d4bce6e99b2ce (diff) |
Fixes #169: made Connection::close() public
-rw-r--r-- | client_ws.hpp | 13 | ||||
-rw-r--r-- | server_ws.hpp | 13 |
2 files changed, 14 insertions, 12 deletions
diff --git a/client_ws.hpp b/client_ws.hpp index 23a8923..48590fa 100644 --- a/client_ws.hpp +++ b/client_ws.hpp @@ -88,12 +88,6 @@ namespace SimpleWeb { asio::ip::tcp::endpoint endpoint; // The endpoint is read in SocketClient::upgrade and must be stored so that it can be read reliably in all handlers, including on_error - void close() noexcept { - error_code ec; - socket->lowest_layer().shutdown(asio::ip::tcp::socket::shutdown_both, ec); - socket->lowest_layer().cancel(ec); - } - void set_timeout(long seconds = -1) noexcept { bool use_timeout_idle = false; if(seconds == -1) { @@ -255,6 +249,13 @@ namespace SimpleWeb { send(out_message, std::move(callback), 136); } + /// Force close connection. Use `send_close()` instead for standard compliant connection close. + void close() noexcept { + error_code ec; + socket->lowest_layer().shutdown(asio::ip::tcp::socket::shutdown_both, ec); + socket->lowest_layer().cancel(ec); + } + const asio::ip::tcp::endpoint &remote_endpoint() const noexcept { return endpoint; } diff --git a/server_ws.hpp b/server_ws.hpp index 715be40..c41ecfa 100644 --- a/server_ws.hpp +++ b/server_ws.hpp @@ -109,12 +109,6 @@ namespace SimpleWeb { asio::ip::tcp::endpoint endpoint; // The endpoint is read in SocketServer::write_handshake and must be stored so that it can be read reliably in all handlers, including on_error - void close() noexcept { - error_code ec; - socket->lowest_layer().shutdown(asio::ip::tcp::socket::shutdown_both, ec); - socket->lowest_layer().cancel(ec); - } - void set_timeout(long seconds = -1) noexcept { if(seconds == -1) seconds = timeout_idle; @@ -259,6 +253,13 @@ namespace SimpleWeb { send(std::move(send_stream), std::move(callback), 136); } + /// Force close connection. Use `send_close()` instead for standard compliant connection close. + void close() noexcept { + error_code ec; + socket->lowest_layer().shutdown(asio::ip::tcp::socket::shutdown_both, ec); + socket->lowest_layer().cancel(ec); + } + const asio::ip::tcp::endpoint &remote_endpoint() const noexcept { return endpoint; } |