Registry / messaging / clhq-websocket-module

clhq-websocket-module

JSON →
library1.1.0-alpha.189jsnpmunverified

A shared WebSocket broadcaster module for ClippyHQ services, currently at version 1.1.0-alpha.189. This alpha release primarily supports server-to-client broadcasting but has a known limitation: client-to-server event handling is not yet implemented. It is designed for internal CLHQ usage, built with TypeScript, and relies on the popular 'ws' library. The package facilitates real-time messaging across Clippy microservices, with a focus on simplicity and TypeScript integration.

npm install clhq-websocket-module
INSTALL
IMPORT
SIG · CLHQ-WEBSOCKET-MOD
C
clhq-websocket-module
messagingjavascriptv1.1.0-alpha.189
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

WebSocketBroadcaster
import { WebSocketBroadcaster } from 'clhq-websocket-module'
const WebSocketBroadcaster = require('clhq-websocket-module');
ESM-only package; CommonJS require() fails.
BroadcasterOptions
import type { BroadcasterOptions } from 'clhq-websocket-module'
import { BroadcasterOptions } from 'clhq-websocket-module'
Type-only import to avoid runtime errors in JavaScript.
default
import Broadcaster from 'clhq-websocket-module'
const Broadcaster = require('clhq-websocket-module').default
The default export is WebSocketBroadcaster.

Initializes a WebSocket broadcaster on port 8080, broadcasts a JSON event, and handles new connections.

import { WebSocketBroadcaster } from 'clhq-websocket-module'; import WebSocket from 'ws'; const broadcaster = new WebSocketBroadcaster({ port: 8080, server: new WebSocket.Server({ port: 8080 }), }); broadcaster.on('connection', (socket) => { console.log('Client connected'); socket.send('Welcome!'); }); broadcaster.broadcast({ event: 'update', data: { message: 'Hello all' } });
Debug
Known issues
breakingWebSocketBroadcaster constructor removed 'ws' option; use 'server' option in v1.1.0-alpha.189
fix
Pass WebSocket.Server instance via 'server' option instead of 'ws'.
affects: >=1.1.0-alpha.189
deprecatedMethod 'sendToAll' is deprecated; use 'broadcast' instead.
fix
Replace calls to 'sendToAll' with 'broadcast'.
affects: >=1.1.0-alpha.180
gotchaClient-to-server events not supported; only server-to-client broadcasting works.
fix
Implement custom client message handling if needed; this is a known limitation.
affects: <=1.1.0-alpha.189
gotchaTypeScript consumers must set 'esModuleInterop' to true or use default import correctly.
fix
Add 'esModuleInterop': true in tsconfig.json or use 'import * as Broadcaster'.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'ws' or its corresponding type declarations.
Missing 'ws' dependency.
fix
Run 'npm install ws' and 'npm install @types/ws' (if using TypeScript).
TypeError: WebSocketBroadcaster is not a constructor
Wrong import style (CommonJS require on an ESM-only package).
fix
Use ES module import: 'import { WebSocketBroadcaster } from 'clhq-websocket-module'
Upgrade
Version history
1.1.0-alpha.189latest on npm
Audit
Dependencies
wsrequiredCore WebSocket implementation
Agent activity
31 hits · last 30 days
node
28
OpenAI (training)
1
Resources
clhq-websocket-module — npm install clhq-websocket-module · libregistry