A Node.js WebSocket server that sends a message every second after a connection is established.
npm installnpm startThe server will start on ws://localhost:8080
- Open
client.htmlin your web browser - Click the "Connect" button
- You will see messages arriving every second
- When a client connects, the server sends a welcome message
- Then it starts sending messages every second (1000ms interval)
- Each message includes a timestamp and a heartbeat message
- The interval is automatically cleaned up when the client disconnects