From cf2a4739f3de86c14aaab2053807dac3b3cd288b Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sun, 29 Dec 2024 02:58:34 -0800 Subject: [PATCH] feat: enable Websocket support --- CMakeLists.txt | 4 ++-- README.md | 17 +++++++++++------ src/socket.cc | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1380b8ee..7e663635 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,10 +41,10 @@ if(ZMQ_SODIUM AND APPLE) message(STATUS "building libsodium requires running `brew install autoconf automake libtool`") endif() -option(ZMQ_WEBSOCKETS "Enable WebSocket transport" OFF) +option(ZMQ_WEBSOCKETS "Enable WebSocket transport" ON) set_option_from_env(ZMQ_WEBSOCKETS) -option(ZMQ_WEBSOCKETS_SECURE "Enable WebSocket transport with TSL (wss)" OFF) +option(ZMQ_WEBSOCKETS_SECURE "Enable WebSocket transport with TSL (wss)" ON) set_option_from_env(ZMQ_WEBSOCKETS_SECURE) option(ZMQ_NO_SYNC_RESOLVE "send/receive on the socket immediately" OFF) diff --git a/README.md b/README.md index 8f193756..7e23652f 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ - Compatible with Zeromq 4/5 via "zeromq/v5-compat" - Secure Curve protocol with Libsodium - Zeromq Draft API support +- Websocket support ## Useful links @@ -30,8 +31,8 @@ - [Installation](#installation) - [Prebuilt binaries](#prebuilt-binaries) - [Building from source](#building-from-source) - - [Available Build Options](#available-build-options) - - [Curve with Libsodium support](#curve-with-libsodium-support) + - [Available Build Options](#available-build-options) + - [Curve with Libsodium support](#curve-with-libsodium-support) - [Draft support](#draft-support) - [Websocket support](#websocket-support) - [Secure Websocket support](#secure-websocket-support) @@ -113,19 +114,19 @@ For Curve: To install from source, specify `build_from_source=true` in a `.npmrc` file -``` +```ini build_from_source=true ``` +#### Available Build Options + When building from source, you can also specify additional build options in a `.npmrc` file in your project: -### Available Build Options -
👉🏻 Options -### Curve with Libsodium support +#### Curve with Libsodium support (Enabled by default) @@ -155,6 +156,8 @@ zmq_draft=false #### Websocket support +(Enabled by default) + Enables WebSocket transport, allowing ZeroMQ to communicate over WebSockets. To enable WebSocket support, add the following to your .npmrc: @@ -164,6 +167,8 @@ zmq_websockets="true" #### Secure Websocket support +(Enabled by default) + Enables WebSocket transport with TLS (wss), providing secure WebSocket communications. To enable secure WebSocket support, add the following to your .npmrc: diff --git a/src/socket.cc b/src/socket.cc index 95385db2..72d73d97 100644 --- a/src/socket.cc +++ b/src/socket.cc @@ -103,7 +103,7 @@ Socket::Socket(const Napi::CallbackInfo& info) return; } - auto file_descriptor = uv_os_sock_t{}; + uv_os_sock_t file_descriptor = 0; const auto error = [this]() { [[maybe_unused]] auto err = zmq_close(socket);