Registry / messaging / adonis-websocket-client

adonis-websocket-client

JSON →
library1.0.2jsnpmunverified

Adonis WebSocket Client (v1.0.2) is a frontend library for communicating with AdonisJs WebSocket servers. It provides a simple API for connecting to channels, emitting messages, and joining/leaving rooms. The package supports both CommonJS and CDN usage, and includes a Vue.js plugin. It is designed to be lightweight and easy to use, with no additional dependencies. However, the package is outdated and relies on the older AdonisJs v4 WebSocket server; it may not be compatible with newer versions. Development is sporadic, and the library has known security issues (no recent updates).

npm install adonis-websocket-client
INSTALL
IMPORT
SIG · ADONIS-WEBSOCKET-C
A
adonis-websocket-client
messagingjavascriptv1.0.2
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.

default
import ws from 'adonis-websocket-client'
const ws = require('adonis-websocket-client')
ESM import is preferred; CommonJS require works but may not be tree-shakeable.
ws (instance)
const io = ws('http://localhost:3333')
const io = new ws('http://localhost:3333')
ws is a factory function, not a constructor.
Vue plugin
import Vue from 'vue'; import wsPlugin from 'adonis-websocket-client/plugin'
const Vue = require('vue'); const wsPlugin = require('adonis-websocket-client').default
The plugin is exported separately; ensure correct path or use the global ws function.

Basic usage: import the client, connect to server, join channel, listen/emit events, and manage rooms.

import ws from 'adonis-websocket-client'; // Initialize connection to server const io = ws('ws://localhost:3333'); // Connect to a channel const chat = io.channel('chat').connect(); // Listen for messages chat.on('message', (msg) => { console.log('Received:', msg); }); // Emit a message chat.emit('message', 'Hello from client!'); // Join a room chat.joinRoom('room1', {}, (error, data) => { if (error) console.error('Join failed', error); else console.log('Joined room:', data); }); // Leave a room chat.leaveRoom('room1', {}, (error, data) => { if (error) console.error('Leave failed', error); else console.log('Left room:', data); });
Debug
Known issues
deprecatedThis package is no longer actively maintained and may have security vulnerabilities.
fix
Consider migrating to a more modern WebSocket client library like Socket.IO or native WebSocket.
affects: >=1.0.0
gotchaThe client requires a running AdonisJs WebSocket server; it is not compatible with generic WebSocket servers.
fix
Ensure your backend uses AdonisJs v4 or earlier; newer versions use different protocols.
affects: >=1.0.0
gotchaThe ws function is a factory, not a constructor. Using 'new ws()' will throw an error.
fix
Call ws(url) directly without the 'new' keyword.
affects: >=1.0.0
gotchaThe Vue plugin is not included in the default export; must import from 'adonis-websocket-client/plugin'.
fix
Use 'import wsPlugin from 'adonis-websocket-client/plugin'; Vue.use(wsPlugin, url, options);'
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: ws is not a constructor
Calling 'new ws()' instead of 'ws()'
fix
Remove the 'new' keyword: const io = ws('http://localhost:3333');
Uncaught ReferenceError: ws is not defined
Forgot to import the library or using the CDN script incorrectly
fix
Ensure you have run 'npm install adonis-websocket-client' and import it, or include the CDN script tag.
Error: Cannot find module 'adonis-websocket-client/plugin'
Typo in import path or the plugin submodule does not exist (check version)
fix
Verify the package version and use: import wsPlugin from 'adonis-websocket-client/dist/plugin' if needed.
WebSocket connection to 'ws://localhost:3333' failed: Connection closed before receiving a handshake response
No AdonisJs WebSocket server running at that URL
fix
Start your AdonisJs server or check the URL.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
34 hits · last 30 days
node
28
OpenAI (training)
1
Resources
adonis-websocket-client — npm install adonis-websocket-client · libregistry