Skip to content

Commit

Permalink
[wasm64] Fix WebSocket API under wasm64
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 committed Mar 11, 2024
1 parent 64feaf1 commit 12608ff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/library_websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ var LibraryWebSocket = {
dbg(`websocket event "open": socketId=${socketId},userData=${userData},callbackFunc=${callbackFunc})`);
#endif
HEAPU32[WS.socketEvent>>2] = socketId;
{{{ makeDynCall('iiii', 'callbackFunc') }}}(0/*TODO*/, WS.socketEvent, userData);
{{{ makeDynCall('iipp', 'callbackFunc') }}}(0/*TODO*/, WS.socketEvent, userData);
}
return {{{ cDefs.EMSCRIPTEN_RESULT_SUCCESS }}};
},
Expand All @@ -181,7 +181,7 @@ var LibraryWebSocket = {
dbg(`websocket event "error": socketId=${socketId},userData=${userData},callbackFunc=${callbackFunc})`);
#endif
HEAPU32[WS.socketEvent>>2] = socketId;
{{{ makeDynCall('iiii', 'callbackFunc') }}}(0/*TODO*/, WS.socketEvent, userData);
{{{ makeDynCall('iipp', 'callbackFunc') }}}(0/*TODO*/, WS.socketEvent, userData);
}
return {{{ cDefs.EMSCRIPTEN_RESULT_SUCCESS }}};
},
Expand Down Expand Up @@ -210,7 +210,7 @@ var LibraryWebSocket = {
HEAPU32[(WS.socketEvent+4)>>2] = e.wasClean;
HEAPU32[(WS.socketEvent+8)>>2] = e.code;
stringToUTF8(e.reason, WS.socketEvent+10, 512);
{{{ makeDynCall('iiii', 'callbackFunc') }}}(0/*TODO*/, WS.socketEvent, userData);
{{{ makeDynCall('iipp', 'callbackFunc') }}}(0/*TODO*/, WS.socketEvent, userData);
}
return {{{ cDefs.EMSCRIPTEN_RESULT_SUCCESS }}};
},
Expand Down Expand Up @@ -262,7 +262,7 @@ var LibraryWebSocket = {
}
HEAPU32[(WS.socketEvent+4)>>2] = buf;
HEAPU32[(WS.socketEvent+8)>>2] = len;
{{{ makeDynCall('iiii', 'callbackFunc') }}}(0/*TODO*/, WS.socketEvent, userData);
{{{ makeDynCall('iipp', 'callbackFunc') }}}(0/*TODO*/, WS.socketEvent, userData);
_free(buf);
}
return {{{ cDefs.EMSCRIPTEN_RESULT_SUCCESS }}};
Expand Down
8 changes: 8 additions & 0 deletions test/test_sockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,11 @@ def test_posix_proxy_sockets(self):
with PythonTcpEchoServerProcess('7777'):
# Build and run the TCP echo client program with Emscripten
self.btest_exit('websocket/tcp_echo_client.c', args=['-lwebsocket', '-sPROXY_POSIX_SOCKETS', '-pthread', '-sPROXY_TO_PTHREAD'])


class sockets64(sockets):
def setUp(self):
super().setUp()
self.set_setting('MEMORY64')
self.emcc_args.append('-Wno-experimental')
self.require_wasm64()

0 comments on commit 12608ff

Please sign in to comment.