Files
spore/test/README
Patrick Balsiger 3cc5405292 feat(streaming): introduce WebSocket Streaming API bridging event bus
ApiServer: add AsyncWebSocket at /ws; accept JSON {event, payload} (string or object) and dispatch via ctx.fire; mirror all local events to clients using NodeContext::onAny.\nNodeContext: add onAny subscriber API.\nNeoPatternService: add api/neopattern/color event to set solid color.\nCluster: centralize cluster/broadcast sending in core; services delegate.\nAPI: add generic /api/node/event and /api/cluster/event endpoints in respective services.\nTests: add ws-color-client, ws-cluster-broadcast-color, http-cluster-broadcast-color.\nDocs: add StreamingAPI.md; update README and test/README.\nFixes: robust WS JSON parsing on ESP8266 and payload handling.
2025-09-28 21:10:26 +02:00

51 lines
1.5 KiB
Plaintext

# Test Scripts
This directory contains JavaScript test scripts to interact with the Spore device, primarily for testing cluster event broadcasting.
## Prerequisites
These scripts require [Node.js](https://nodejs.org/) to be installed on your system.
## How to Run
### 1. HTTP Cluster Broadcast Color (`test/http-cluster-broadcast-color.js`)
This script sends HTTP POST requests to the `/api/cluster/event` endpoint on your Spore device. It broadcasts NeoPattern color changes across the cluster every 5 seconds.
**Usage:**
```
node test/http-cluster-broadcast-color.js <device-ip>
```
Example:
```
node test/http-cluster-broadcast-color.js 10.0.1.53
```
This will broadcast `{ event: "api/neopattern/color", data: { color: "#RRGGBB", brightness: 128 } }` every 5 seconds to the cluster via `/api/cluster/event`.
### 2. WS Local Color Setter (`test/ws-color-client.js`)
Connects to the device WebSocket (`/ws`) and sets a solid color locally (non-broadcast) every 5 seconds by firing `api/neopattern/color`.
**Usage:**
```
node test/ws-color-client.js ws://<device-ip>/ws
```
Example:
```
node test/ws-color-client.js ws://10.0.1.53/ws
```
### 3. WS Cluster Broadcast Color (`test/ws-cluster-broadcast-color.js`)
Connects to the device WebSocket (`/ws`) and broadcasts a color change to all peers every 5 seconds by firing `cluster/broadcast` with the proper envelope.
**Usage:**
```
node test/ws-cluster-broadcast-color.js ws://<device-ip>/ws
```
Example:
```
node test/ws-cluster-broadcast-color.js ws://10.0.1.53/ws
```