Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib/libwebsocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ var LibraryWebSocket = {
},

emscripten_websocket_new__proxy: 'sync',
emscripten_websocket_new__deps: ['$webSockets'],
emscripten_websocket_new: (createAttributes) => {
if (!globalThis.WebSocket) {
#if WEBSOCKET_DEBUG
Expand Down
3 changes: 3 additions & 0 deletions test/test_sockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,9 @@ def test_websocket_send(self, args):
with NodeJsWebSocketEchoServerProcess():
self.btest_exit('websocket/test_websocket_send.c', cflags=['-lwebsocket', '-sNO_EXIT_RUNTIME', '-sWEBSOCKET_DEBUG'] + args)

def test_websocket_new(self):
self.btest_exit('websocket/test_websocket_new.c', cflags=['-lwebsocket'])

# Test that native POSIX sockets API can be used by proxying calls to an intermediate WebSockets
# -> POSIX sockets bridge server
@requires_shared_array_buffer
Expand Down
14 changes: 14 additions & 0 deletions test/websocket/test_websocket_new.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <emscripten/websocket.h>
#include <assert.h>

int main() {
EMSCRIPTEN_WEBSOCKET_T s =
emscripten_websocket_new(&(EmscriptenWebSocketCreateAttributes){
.url = "ws://localhost:9000",
.protocols = "text",
});

assert(s > 0);

return 0;
}