1.1.3 • Published 15 days ago

wandering-willow-websocket v1.1.3

Weekly downloads
-
License
MIT
Repository
-
Last release
15 days ago

Wandering Willow WebSocket

A lightweight wrapper around WebSockets for easy real-time communication in JavaScript, "wandering-willow-websocket" aims to simplify the process of establishing, managing, and closing WebSocket connections.

Features

  • Easy WebSocket connection management
  • Automatic reconnection support
  • Event-based interface for open, message, close, and error events
  • Unique ID generation for clients

Installation

npm install wandering-willow-websocket

Usage

const WanderingWillowWebSocket = require('wandering-willow-websocket');

const ws = new WanderingWillowWebSocket('ws://example.com');

ws.on('open', () => {
console.log('Connection opened');
ws.send('Hello, world!');
});

ws.on('message', (message) => {
console.log('Received:', message);
});

ws.on('close', () => {
console.log('Connection closed');
});

ws.on('error', (error) => {
console.error('Error:', error);
});

API

  • send(data): Send data through the WebSocket connection.
  • close(): Close the WebSocket connection.
  • static generateId(): Generate a unique ID.

License

MIT

1.1.3

15 days ago

1.1.0

2 months ago