A WebSocket demo application for EdgeOne Pages, featuring echo messaging, latency testing, heartbeat keep-alive, and auto reconnection.
More Templates: EdgeOne Pages
npm install├── index.html # Main HTML page
├── client.js # Client-side WebSocket logic
└── node-functions/
└── websocket.ts # Server-side WebSocket handler
All messages use JSON format: { "type": "<type>", "data": "<payload>" }
| Type | Direction | Description |
|---|---|---|
ready |
Server → Client | Connection established |
ping |
Client → Server | Latency test request |
pong |
Server → Client | Latency test response |
echo |
Bidirectional | Echo message back |
heartbeat |
Client → Server | Keep-alive signal |