Skip to content

Latest commit

 

History

History
37 lines (25 loc) · 931 Bytes

README.md

File metadata and controls

37 lines (25 loc) · 931 Bytes

pusher-websocket-go

Go client (WebSocket) library for Pusher.

Status: Not currently recommended for production use. The code connects, receives messages, and reconnects on failure, but there are no tests, interfaces may change, and there are a few missing features (see todo list below).

Usage

Create a new client. It establishes a WebSocket connection and handles automatic reconnection.

client := pusher.New("<key>")

Subscribe to one or more Pusher channels. There is no need to wait for the client to connect before subscribing.

channel := pusher.Subscribe("<channel>")

To bind to events:

channel.bind("my-event", func(data interface{}){
  fmt.Println(data)
})

client.bind(func (channel string, event string, data interface{}) {
  fmt.Println(channel, event, data)
})

TODO

  • Read close code, adjust reconnect behaviour
  • Expose client connection state changes