@robinpath/socket
0.1.0PublicWebSocket client for real-time communication
@robinpath/socket
WebSocket client for real-time communication with message history, handlers, and connection management
Why use this module?
The socket module lets you:
- Send a message through a WebSocket connection
- Wait for and receive the next message
- Get recent message history
- Check if a WebSocket is connected
- Close a WebSocket connection
All functions are callable directly from RobinPath scripts with a simple, consistent API.
Installation
npm install @robinpath/socket
Quick Start
1. Set up credentials
socket.connect "slack" "wss://wss.slack.com/link"
2. Send a message through a WebSocket connection
socket.send "slack" {"type": "message", "text": "Hello"}
Available Functions
| Function | Description |
|---|---|
socket.connect | Connect to a WebSocket server |
socket.send | Send a message through a WebSocket connection |
socket.receive | Wait for and receive the next message |
socket.messages | Get recent message history |
socket.isConnected | Check if a WebSocket is connected |
socket.close | Close a WebSocket connection |
socket.onMessage | Register a handler for incoming messages |
socket.ping | Send a ping to keep the connection alive |
Examples
Send a message through a WebSocket connection
socket.send "slack" {"type": "message", "text": "Hello"}
Wait for and receive the next message
socket.receive "slack" 5000
Get recent message history
socket.messages "slack" 10
Integration with RobinPath
import { RobinPath } from "@wiredwp/robinpath";
import Module from "@robinpath/socket";
const rp = new RobinPath();
rp.registerModule(Module.name, Module.functions);
rp.registerModuleMeta(Module.name, Module.functionMetadata);
const result = await rp.executeScript(`
socket.connect "slack" "wss://wss.slack.com/link"
socket.send "slack" {"type": "message", "text": "Hello"}
`);
Full API Reference
See MODULE.md for complete documentation including all parameters, return types, error handling, and advanced examples.
Related Modules
@robinpath/json— JSON module for complementary functionality
License
MIT
Versions (1)
| Version | Tag | Published |
|---|---|---|
| 0.1.0 | latest | yesterday |
Related Modules
@robinpath/api
HTTP client for making requests to external APIs with profiles, auth, download/upload, and auto-JSON parsing
@robinpath/auth
API authentication helpers (Basic, Bearer, API key, HMAC) for RobinPath
@robinpath/browser
Headless browser automation with Puppeteer: launch browsers, navigate pages, interact with elements, take screenshots, generate PDFs, and scrape data
@robinpath/cookie
HTTP cookie parsing, serialization, signing/verification, Set-Cookie handling, and cookie jar management
$ robinpath install @robinpath/socket
