Skip to content

Mirror of the now defunct thebotguys signalr repository

License

Notifications You must be signed in to change notification settings

benjfield/signalr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SignalR Golang Wrapper

This library allows to connect to a server using SignalR protocol.

Getting the package

go get the package:

$ go get github.com/thebotguys/signalr

Then import it in your code:

import "github.com/thebotguys/signalr"

Usage

First of all create a client:

client := signalr.NewWebsocketClient()

Assign some functions:

client.OnClientMethod = func(hub, method string, arguments []json.RawMessage) {
    fmt.Println("Message Received: ")
    fmt.Println("HUB: ", hub)
    fmt.Println("METHOD: ", method)
    fmt.Println("ARGUMENTS: ", arguments)
}
client.OnErrorMethod = func (err error) {
   fmt.Println("ERROR OCCURRED: ", err)
}

Then connect it:

client.Connect("https", "destinationurl.com", []string{"hub1", "hub2"}) //and so forth

If you want to send messages to the server, use CallHub function:

client.CallHub("hub1", "GET", "params", 1, 1.4, "every type is accepted")

When you are done, just close the client’s websocket:

client.Close()

Known issues

Calling CallHub without connecting a client will result in an infinite wait.

About

Mirror of the now defunct thebotguys signalr repository

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%