diff options
Diffstat (limited to 'modules/websocket/lws_client.cpp')
-rw-r--r-- | modules/websocket/lws_client.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/modules/websocket/lws_client.cpp b/modules/websocket/lws_client.cpp index ac31daa108..09f6422058 100644 --- a/modules/websocket/lws_client.cpp +++ b/modules/websocket/lws_client.cpp @@ -48,12 +48,10 @@ Error LWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port, ERR_FAIL_COND_V(!addr.is_valid(), ERR_INVALID_PARAMETER); - // prepare protocols - if (p_protocols.size() == 0) // default to binary protocol - p_protocols.append("binary"); + // Prepare protocols _lws_make_protocols(this, &LWSClient::_lws_gd_callback, p_protocols, &_lws_ref); - // init lws client + // Init lws client struct lws_context_creation_info info; struct lws_client_connect_info i; @@ -87,7 +85,10 @@ Error LWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port, strncpy(pbuf, p_path.utf8().get_data(), 2048); i.context = context; - i.protocol = _lws_ref->lws_names; + if (p_protocols.size() > 0) + i.protocol = _lws_ref->lws_names; + else + i.protocol = NULL; i.address = abuf; i.host = hbuf; i.path = pbuf; @@ -134,13 +135,13 @@ int LWSClient::_handle_cb(struct lws *wsi, enum lws_callback_reasons reason, voi case LWS_CALLBACK_CLIENT_CONNECTION_ERROR: _on_error(); destroy_context(); - return -1; // we should close the connection (would probably happen anyway) + return -1; // We should close the connection (would probably happen anyway) case LWS_CALLBACK_CLIENT_CLOSED: peer->close(); destroy_context(); _on_disconnect(); - return 0; // we can end here + return 0; // We can end here case LWS_CALLBACK_CLIENT_RECEIVE: peer->read_wsi(in, len); |