https://github.com/thgh/websocket-room
Alternative to websocket.in
https://github.com/thgh/websocket-room
Last synced: about 1 year ago
JSON representation
Alternative to websocket.in
- Host: GitHub
- URL: https://github.com/thgh/websocket-room
- Owner: thgh
- Created: 2019-03-18T20:47:59.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-26T13:04:09.000Z (about 7 years ago)
- Last Synced: 2025-02-05T14:13:40.488Z (over 1 year ago)
- Language: JavaScript
- Size: 33.2 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
websocket-room
---
This websocket server will broadcast all messages it receives to sockets connected to the same URL.
Client-side, you can connect with `new WebSocket(url)`, or use the wrapper in `public/connectable.js` that will try to reconnect.
```
// Connect to `room-name`
const socket = connectable('ws://localhost:8080/room-name')
// Log all messages in `room-name`
socket.subscribe(console.log)
// Send a chat message
form.onsubmit = () => socket.send(nameInput.value)
```