reticulum-js
    Preparing search index...

    Module @reticulum/websocket-server-node

    Node.js WebSocket server interface for @reticulum/core.

    The browser-safe core (@reticulum/core) ships only the WebSocketClientInterface — a server needs a WebSocket server, which browsers cannot run and Node does not ship natively. This companion listens for inbound WebSocket connections and spawns a WebSocketClientInterface per accepted connection (adopting the socket), mirroring TCPServerInterface. Backed by ws.

    import { WebSocketServerInterface } from "@reticulum/websocket-server-node";
    const server = new WebSocketServerInterface({ listenPort: 4242 });
    await server.connect();

    @reticulum/websocket-server-node

    Node.js WebSocket server interface for @reticulum/core, backed by ws.

    The @reticulum/core core ships the WebSocketClientInterface (a WebSocket client, browser-safe via Web APIs). A WebSocket server, however, cannot run in a browser and Node does not ship one natively. This companion listens for inbound WebSocket connections and spawns a WebSocketClientInterface per accepted connection, mirroring TCPServerInterface.

    npm install @reticulum/websocket-server-node
    

    This depends on @reticulum/core and ws automatically.

    import { Reticulum } from "@reticulum/core";
    import { WebSocketServerInterface } from "@reticulum/websocket-server-node";

    const rns = new Reticulum();

    const server = new WebSocketServerInterface({ listenPort: 4242 });
    server.addEventListener("connection", (event) => {
    // Each accepted connection is a spawned WebSocketClientInterface; attach it
    // to the transport. The server copies its bitrate onto each spawned client.
    rns.addInterface(event.detail, false);
    });
    await server.connect();

    Set framing: "kiss" for RNode-style KISS-over-WebSocket peers (defaults to raw).

    Export Interface id Runtime deps Notes
    WebSocketServerInterface ws-server ws Spawns a WebSocketClientInterface per accepted connection; server itself never carries packets

    Note: the interface registry in @reticulum/node does not register ws-server (that would force it to depend on ws). Register it yourself with registerInterface if you want it in a schema enumeration.

    Licensed under the EUPL 1.2. See the monorepo README for project-wide information.

    WebSocketServerInterface
    WebSocketServerInterfaceOptions