https://github.com/fardinak/websocket
An opinionated WebSocket Server in Golang
https://github.com/fardinak/websocket
golang golang-module websocket websocket-server
Last synced: 5 months ago
JSON representation
An opinionated WebSocket Server in Golang
- Host: GitHub
- URL: https://github.com/fardinak/websocket
- Owner: Fardinak
- License: mit
- Created: 2021-05-24T13:32:03.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-25T17:36:20.000Z (about 5 years ago)
- Last Synced: 2024-06-21T12:16:00.303Z (about 2 years ago)
- Topics: golang, golang-module, websocket, websocket-server
- Language: Go
- Homepage: https://pkg.go.dev/github.com/Fardinak/websocket
- Size: 14.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WebSocket
[](https://github.com/Fardinak/websocket/blob/master/LICENSE)


[](https://pkg.go.dev/github.com/Fardinak/websocket)
A WebSocket Server with Subprotocol support.
## Features
### Socket handling
We use goroutines + channels to read from and write to a WebSocket.
PING/PONG messages are also handled internally.
### Subprotocol registry
An API is provided to create subprotocols and register messages to them.
### Message encoding
Message names (topics) are strings with a maximum length of 225 bytes, and the payload is a byte array. You can use any
encoder/decoder you like as long as you can decode/encode it at the client.
### Socket management
Socket operations are handled internally with sane defaults. There is an optional `ClientID` function that will run on
each new connection, allowing you to group sockets by user ID or any other identifier.
### Rooms
You can further group clients into rooms
## TODO
- [ ] Unit tests
- [ ] JS-Client implementation
- [ ] Client implementation
- [ ] More configurability
- [ ] Default subprotocol
- [ ] Logging interface instead of `logrus.Entry`
- [ ] More comments
- [ ] JSONSubprotocol: a subprotocol that works with `interface{}` instead of `[]byte` and encodes to/decodes from JSON
## Credit
This library is a wrapper around the `gorilla/websocket` implementation.