Node.js implementation of the Hello WebSocket protocol using ws.
hello-websocket-nodejs/
├── package.json # npm package definition
├── common/
│ ├── codec.js # Binary protocol codec
│ └── codec.test.js # Codec unit tests
├── server/
│ └── ws_server.js # WebSocket server
├── client/
│ └── ws_client.js # WebSocket client
├── scripts/
│ ├── build.sh # Install and test
│ ├── run-server.sh # Run server
│ └── run-client.sh # Run client
└── README.md
- Node.js 18+
./scripts/build.shOr manually:
npm install
npm test./scripts/run-server.shEnvironment variables:
WS_PORT— Port to listen on (default: 9898)WS_PATH— WebSocket path (default: /ws)
./scripts/run-client.shEnvironment variables:
WS_SERVER— Server host (default: 127.0.0.1)WS_PORT— Server port (default: 9898)WS_PATH— WebSocket path (default: /ws)
See ../PROTOCOL.md for the canonical protocol specification.