From d02a29f0ff33279268e675aae0856f3f8cf9d939 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Tue, 10 Jan 2023 14:22:47 +0100 Subject: Configurable Websocket für HTTPS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- websocket.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'websocket.h') diff --git a/websocket.h b/websocket.h index 1611c45..85492f2 100644 --- a/websocket.h +++ b/websocket.h @@ -49,14 +49,23 @@ class websocket_session: public std::enable_shared_from_this std::string port_; public: - explicit websocket_session(boost::asio::io_context& ioc, beast::ssl_stream&& stream): + explicit websocket_session(boost::asio::io_context& ioc, beast::ssl_stream&& stream, const std::string& websocket_address): ioc_(ioc), resolver_(boost::asio::make_strand(ioc_)), ws_in_(std::move(stream)), ws_app_(boost::asio::make_strand(ioc_)), - host_{"::1"}, - port_{"9876"} + host_{}, + port_{} { + // Parse websocket address host:port : + + auto pos{websocket_address.find_last_of(':')}; + + if (pos == std::string::npos) + return; + + host_ = websocket_address.substr(0, pos); + port_ = websocket_address.substr(pos + 1); } // -- cgit v1.2.3