| 228 | } |
| 229 | |
| 230 | bool WebSocket::open(Delegate* delegate, |
| 231 | std::string_view url, |
| 232 | std::string_view caFilePath, |
| 233 | std::string_view protocols) |
| 234 | { |
| 235 | _delegate = delegate; |
| 236 | _url = url; |
| 237 | _caFilePath = FileUtils::getInstance()->fullPathForFilename(caFilePath); |
| 238 | _requestUri = Uri::parse(url); |
| 239 | _protocols = protocols; |
| 240 | _closeCode = ws::detail::close_code::none; |
| 241 | _closeReason = ""; |
| 242 | |
| 243 | setupParsers(); |
| 244 | generateHandshakeSecKey(); |
| 245 | |
| 246 | if (!_caFilePath.empty()) |
| 247 | _service->set_option(YOPT_S_SSL_CACERT, _caFilePath.c_str()); |
| 248 | |
| 249 | _service->set_option(YOPT_C_REMOTE_ENDPOINT, 0, _requestUri.getHost().data(), (int)_requestUri.getPort()); |
| 250 | |
| 251 | _state = State::CONNECTING; |
| 252 | if (_requestUri.isSecure()) |
| 253 | _service->open(0, YCK_SSL_CLIENT); |
| 254 | else |
| 255 | _service->open(0, YCK_TCP_CLIENT); |
| 256 | |
| 257 | return true; |
| 258 | } |
| 259 | |
| 260 | void WebSocket::purgePendingEvents() |
| 261 | { |