Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable Websocket support #692

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down Expand Up @@ -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

<details>
<summary>👉🏻 Options</summary>

### Curve with Libsodium support
#### Curve with Libsodium support

(Enabled by default)

Expand Down Expand Up @@ -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:

Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading