Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/coinrust/wsconn
wsconn is a websocket client based on gorilla/websocket that will automatically reconnect if the connection is dropped and keeps the connection alive.
https://github.com/coinrust/wsconn
gorilla websocket websocket-client wsconn
Last synced: 3 months ago
JSON representation
wsconn is a websocket client based on gorilla/websocket that will automatically reconnect if the connection is dropped and keeps the connection alive.
- Host: GitHub
- URL: https://github.com/coinrust/wsconn
- Owner: coinrust
- License: mit
- Created: 2020-05-02T01:54:25.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-04-29T21:31:11.000Z (almost 4 years ago)
- Last Synced: 2024-06-21T18:08:09.585Z (8 months ago)
- Topics: gorilla, websocket, websocket-client, wsconn
- Language: Go
- Size: 12.7 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# wsconn
wsconn is a websocket client based on gorilla/websocket that will automatically reconnect if the connection is dropped and keeps the connection alive.## Example
```go
package mainimport (
"fmt"
"github.com/coinrust/wsconn"
"log"
)func main() {
wsURL := "wss://api.zb.live/websocket"
ws := wsconn.NewWs(
wsconn.WsUrlOption(wsURL),
wsconn.WsDumpOption(true),
wsconn.WsAutoReconnectOption(true),
wsconn.WsMessageHandleFuncOption(func(bytes []byte) error {
log.Printf("%v", string(bytes))
return nil
}),
wsconn.WsErrorHandleFuncOption(func(err error) {
log.Printf("%v", err)
}),
)
ch := fmt.Sprintf("%v_depth", "zbqc") // zbqc_depth
sub := map[string]string{
"event": "addChannel",
"channel": ch,
}
ws.Subscribe(sub)select {}
}
```