Details
-
Bug
-
Resolution: Done
-
P2: Important
-
None
-
5.11.0
-
None
-
emsdk clang e1.38.11_64bit
Description
function onMessage(evt) { var ptr; var bufferLength = 0; var dataType; if (window.webSocker.binaryType == "arraybuffer" && typeof evt.data == "object") { var byteArray = new Uint8Array(evt.data); bufferLength = byteArray.length; ptr = _malloc(byteArray.length); HEAP8.set(byteArray, ptr); dataType = 2; } else if (window.webSocker.binaryType == "blob") { var byteArray = new Int8Array($0); console.log("type blob"); ptr = new Blob(byteArray.buffer); dataType = 1; } else if (typeof evt.data == "string") { dataType = 0; ptr = allocate(intArrayFromString(evt.data), 'i8', ALLOC_NORMAL); } Runtime.dynCall('viiii', onIncomingMessageCallback, [handler, ptr, bufferLength, dataType]); _free(ptr); }
The above onMessage JavaScript function is from qwebsocket_wasm_p.cpp. As you can see a string will never be emit by QWebSocket::textMessageReceived if window.webSocker.binaryType == "blob". It seams the default binaryType is "blob", so the string case is never executed.
Workaround: When QWebSocket::connected is emit call QWebSocket::ping(). This will internally send a binary frames and changes the window.webSocker.binaryType to "arraybuffer" so the string case in the above function will now be executed.