summaryrefslogtreecommitdiffstats
path: root/modules/websocket/emws_client.cpp
diff options
context:
space:
mode:
authorMax Hilbrunner <mhilbrunner@users.noreply.github.com>2018-08-31 13:15:46 +0200
committerGitHub <noreply@github.com>2018-08-31 13:15:46 +0200
commit21ea1d89efcf6e25669831baf7b7c9092d3850b1 (patch)
tree39fe2cb2256baaffdd2b9379096612c3f3d10f77 /modules/websocket/emws_client.cpp
parentfaa69665e3991f1dec046e619d129831d11dbc42 (diff)
parent6bc97cc7cc86bff790fd63c28a48d76f845b4844 (diff)
downloadredot-engine-21ea1d89efcf6e25669831baf7b7c9092d3850b1.tar.gz
Merge pull request #21605 from Faless/ws_no_proto
Allow WebSocket connect with no sub-protocols.
Diffstat (limited to 'modules/websocket/emws_client.cpp')
-rw-r--r--modules/websocket/emws_client.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/modules/websocket/emws_client.cpp b/modules/websocket/emws_client.cpp
index 00c36ebb47..836b564de8 100644
--- a/modules/websocket/emws_client.cpp
+++ b/modules/websocket/emws_client.cpp
@@ -62,25 +62,23 @@ EMSCRIPTEN_KEEPALIVE void _esws_on_close(void *obj, int code, char *reason, int
Error EMWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, PoolVector<String> p_protocols) {
+ String proto_string = p_protocols.join(",");
String str = "ws://";
- String proto_string = "";
if (p_ssl)
str = "wss://";
str += p_host + ":" + itos(p_port) + p_path;
- for (int i = 0; i < p_protocols.size(); i++) {
- proto_string += p_protocols[i];
- proto_string += ",";
- }
- if (proto_string == "")
- proto_string = "binary,";
-
- proto_string = proto_string.substr(0, proto_string.length() - 1);
_is_connecting = true;
/* clang-format off */
int peer_sock = EM_ASM_INT({
- var socket = new WebSocket(UTF8ToString($1), UTF8ToString($2).split(","));
+ var proto_str = UTF8ToString($2);
+ var socket = null;
+ if (proto_str) {
+ socket = new WebSocket(UTF8ToString($1), proto_str.split(","));
+ } else {
+ socket = new WebSocket(UTF8ToString($1));
+ }
var c_ptr = Module.IDHandler.get($0);
socket.binaryType = "arraybuffer";