This is my personal attempt at implementating the client side of the WebSocket portion of the SignalR protocol. I use it for various virtual currency trading platforms that use SignalR.
Simple example:
package main
import (
"log"
"github.com/rainhq/signalr/v2"
)
func main() {
ctx := context.Background()
// Prepare a SignalR client.
c, err := signalr.Dial(
ctx,
"https://fake-server.definitely-not-real/signalr",
`[{"name":"awesomehub"}]`,
)
if err != nil {
log.Fatal(err)
}
var msg signalr.Message
for {
if err := c.ReadMessage(ctx, &msg); err != nil {
log.Fatal(err)
}
log.Println(msg)
}
}
Generic usage:
Cryptocurrency examples:
Proxy examples:
- SignalR specification: https://docs.microsoft.com/en-us/aspnet/signalr/overview/
- Excellent technical deep dive of the protocol: https://blog.3d-logic.com/2015/03/29/signalr-on-the-wire-an-informal-description-of-the-signalr-protocol/
If anything is unclear or could be improved, please open an issue or submit a pull request. Thanks!