Skip to content

Commit

Permalink
feat: enable Websocket support
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jan 5, 2025
1 parent 0f85318 commit cf2a473
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
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

0 comments on commit cf2a473

Please sign in to comment.