1.0.1 • Published 1 year ago
socket-insight v1.0.1
SocketInsight
SocketInsight is a production-grade real-time WebSockets debugging package that allows developers to efficiently monitor and debug WebSocket connections in real time. It provides an easy-to-use API for handling WebSocket events, messages, and errors, making WebSocket debugging simpler and more efficient.
Installation
To install SocketInsight, use one of the following commands:
# Using npm
npm install socket-insight
# Or using yarn
yarn add socket-insight
Usage: mycli [options]
Foos your bar.
Options:
-b, --bar <string> foo what?
-h, --help display help for command
API Documentation
import SocketInsight from 'socket-insight';
// Create a new instance of SocketInsight
const url = 'wss://echo.websocket.org';
const debuggerInstance = new SocketInsight(url, {
retryAttempts: 3, // Number of retry attempts after disconnection
retryDelay: 1000 // Delay between retry attempts in milliseconds
});
// Register event listeners
debuggerInstance.on('open', () => console.log('Connected to WebSocket.'));
debuggerInstance.on('message', (message) => console.log('Received message:', message));
debuggerInstance.on('close', (code, reason) => console.log('Disconnected:', code, reason));
debuggerInstance.on('error', (error) => console.error('Error:', error));
// Send a message through the WebSocket
debuggerInstance.sendMessage('Hello, WebSocket!');
// Close the connection
debuggerInstance.closeConnection();
Function Documentation
foo(value) ⇒ any
Returns whatever value is passed.
Kind: global function
Returns: any - Whatever value it was passed.
| Param | Type | Description |
Connect with Me
Stay updated with the latest news and updates. Follow me on social media:
See more great templates and other tools on my GitHub Profile!