Browse Source

fixed build failed for macos

홍학규 4 years ago
parent
commit
6aff5dc5bc
2 changed files with 8 additions and 2 deletions
  1. 1 1
      include/rtc/websocket.hpp
  2. 7 1
      src/websocket.cpp

+ 1 - 1
include/rtc/websocket.hpp

@@ -49,7 +49,7 @@ public:
 
 
 	struct Configuration {
 	struct Configuration {
 		bool disableTlsVerification = false; // if true, don't verify the TLS certificate
 		bool disableTlsVerification = false; // if true, don't verify the TLS certificate
-		std::vector<string> protocols;
+		std::optional<std::vector<string>> protocols = std::nullopt;
 	};
 	};
 
 
 	WebSocket(std::optional<Configuration> config = nullopt);
 	WebSocket(std::optional<Configuration> config = nullopt);

+ 7 - 1
src/websocket.cpp

@@ -287,8 +287,14 @@ shared_ptr<WsTransport> WebSocket::initWsTransport() {
 		shared_ptr<Transport> lower = std::atomic_load(&mTlsTransport);
 		shared_ptr<Transport> lower = std::atomic_load(&mTlsTransport);
 		if (!lower)
 		if (!lower)
 			lower = std::atomic_load(&mTcpTransport);
 			lower = std::atomic_load(&mTcpTransport);
+
+		auto wsConfig = WsTransport::Configuration();
+		if(mConfig.protocols) {
+			wsConfig.protocols = *mConfig.protocols;
+		}
+
 		auto transport = std::make_shared<WsTransport>(
 		auto transport = std::make_shared<WsTransport>(
-			WsTransport::Configuration{{.protocols = mConfig.protocols}},
+			wsConfig,
 		    lower, mHost, mPath, weak_bind(&WebSocket::incoming, this, _1),
 		    lower, mHost, mPath, weak_bind(&WebSocket::incoming, this, _1),
 		    [this, weak_this = weak_from_this()](State state) {
 		    [this, weak_this = weak_from_this()](State state) {
 			    auto shared_this = weak_this.lock();
 			    auto shared_this = weak_this.lock();