Modules@robinpath/socket

@robinpath/socket

0.1.0Public

WebSocket client for real-time communication

@robinpath/socket

WebSocket client for real-time communication with message history, handlers, and connection management

Category Functions Auth License

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

FunctionDescription
socket.connectConnect to a WebSocket server
socket.sendSend a message through a WebSocket connection
socket.receiveWait for and receive the next message
socket.messagesGet recent message history
socket.isConnectedCheck if a WebSocket is connected
socket.closeClose a WebSocket connection
socket.onMessageRegister a handler for incoming messages
socket.pingSend 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

License

MIT

Versions (1)

VersionTagPublished
0.1.0latestyesterday
Install
$ robinpath install @robinpath/socket
Version0.1.0
LicenseMIT
Unpacked Size4.4 KB
Versions1
Weekly Downloads0
Total Downloads0
Stars0
Last Publishyesterday
Createdyesterday

Category

web