Registry / communication / w-comor-websocket

w-comor-websocket

JSON →
library1.0.38jsnpmunverified

A WebSocket RPC communicator for Node.js and browser, version 1.0.38. Provides a simple RPC-like mechanism mapping server functions to client calls with authentication, function filtering, and client change events. Released on npm with moderate download activity. Key differentiators: built-in authentication and function filtering, support for both server and client UMD modules, and dependency on ws and w-websocket-client. Suitable for projects needing lightweight WebSocket-based RPC without a full framework.

npm install w-comor-websocket
INSTALL
IMPORT
SIG · W-COMOR-WEBSOCKET
W
w-comor-websocket
communicationjavascriptv1.0.38
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.

WComorWebsocketServer
import WComorWebsocketServer from 'w-comor-websocket/dist/w-comor-websocket-server.umd.js'
const WComorWebsocketServer = require('w-comor-websocket/dist/w-comor-websocket-server.umd.js')
Use default import; ESM-only. Avoid CommonJS require.
WComorWebsocketClient
import WComorWebsocketClient from 'w-comor-websocket/dist/w-comor-websocket-client.umd.js'
import { WComorWebsocketClient } from 'w-comor-websocket'
Named import is incorrect; must use default import from the specific client UMD file.
WComorWebsocketServer
const WComorWebsocketServer = await import('w-comor-websocket/dist/w-comor-websocket-server.umd.js')
const WComorWebsocketServer = require('w-comor-websocket')
Dynamic import works; require from top-level package does not.

Initializes a WebSocket RPC server with authentication and a ping function, then client connects and calls the function.

import WComorWebsocketServer from 'w-comor-websocket/dist/w-comor-websocket-server.umd.js' import WComorWebsocketClient from 'w-comor-websocket/dist/w-comor-websocket-client.umd.js' const server = new WComorWebsocketServer({ port: 8080, authenticate: async (token) => token === 'secret', funcs: { 'ping': async ({ msg }) => `pong ${msg}` } }) const client = new WComorWebsocketClient({ url: 'ws://localhost:8080', token: 'secret' }) client.call('ping', { msg: 'hello' }).then(console.log) // pong hello
Debug
Known issues
gotchaImport path must specify the exact UMD file; top-level package import does not work.
fix
Use 'w-comor-websocket/dist/w-comor-websocket-server.umd.js' or 'w-comor-websocket/dist/w-comor-websocket-client.umd.js'.
affects: >=1.0.0
gotchaClient requires token authentication; server authenticate function must be async or return Promise.
fix
Ensure server authenticate returns a boolean via async/Promise.
affects: >=1.0.0
gotchaFunction names must be unique; no two funcs with same key.
fix
Use descriptive keys like 'group.plus' instead of duplicates.
affects: >=1.0.0
gotchaClient call() expects an object argument; passing primitive will break.
fix
Always wrap arguments in an object: client.call('func', { p1: 1, p2: 2 })
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: WComorWebsocketServer is not a constructor
Importing from the wrong path (e.g., 'w-comor-websocket' instead of specific UMD file).
fix
import WComorWebsocketServer from 'w-comor-websocket/dist/w-comor-websocket-server.umd.js'
Uncaught ReferenceError: module is not defined
Using CommonJS require in an ESM environment.
fix
Use import statement instead of require().
Error: ECONNREFUSED ws://localhost:8080
Server is not running or wrong port.
fix
Ensure server is started on the correct port (e.g., 8080) and client URL matches.
Upgrade
Version history
1.0.38latest on npm
Audit
Dependencies
wsrequiredWebSocket server implementation for Node.js
w-websocket-clientrequiredClient WebSocket wrapper for Node.js and browser
Agent activity
39 hits · last 30 days
node
30
OpenAI (training)
1
Resources
w-comor-websocket — npm install w-comor-websocket · libregistry