summaryrefslogtreecommitdiffhomepage
path: root/websocket.h
diff options
context:
space:
mode:
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);
}
//