This project demonstrates a simple proof of concept for a WebSocket server built with Node.js and Express. The server is capable of accepting WebSocket connections and broadcasting messages to all connected clients.
To get started with this project, clone the repository and install the dependencies.
git clone https://github.com/ryanjwise/websocket_example
cd websocket_poc
npm installTo run the server, execute the following command:
npm startTo lint the project and automatically fix any linting errors, run:
bash npm run lint app/server.mjs: The main server file where the WebSocket server is initialized.public/: Contains static files that are served by the Express application.index.html: The main HTML file that establishes a WebSocket connection when accessed via a web browser.client.js: The JavaScript file included byindex.htmlthat handles the WebSocket client logic.
The WebSocket server listens on the following endpoint for incoming WebSocket connections:
ws://localhost:3000
Contributions to this project are welcome. Please feel free to submit issues, pull requests, or enhancements.
This project is licensed under the CC0 License - see the LICENSE file for details.