summaryrefslogtreecommitdiffhomepage
path: root/websocket.h
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2023-01-10 14:22:47 +0100
committerRoland Reichwein <mail@reichwein.it>2023-01-10 14:22:47 +0100
commitd02a29f0ff33279268e675aae0856f3f8cf9d939 (patch)
treebbb22aeb9c14488ef0871b34f0400259658d46f0 /websocket.h
parent1191f07767583a9b19280a4f29cb1b0bd6799785 (diff)
Configurable Websocket für HTTPS
Diffstat (limited to 'websocket.h')
-rw-r--r--websocket.h15
1 files changed, 12 insertions, 3 deletions
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<websocket_session>
std::string port_;
public:
- explicit websocket_session(boost::asio::io_context& ioc, beast::ssl_stream<beast::tcp_stream>&& stream):
+ explicit websocket_session(boost::asio::io_context& ioc, beast::ssl_stream<beast::tcp_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);
}
//