-
Notifications
You must be signed in to change notification settings - Fork 8
/
doc.go
44 lines (44 loc) · 1.5 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Package gobayeux provides both a low-level protocol client and a
// higher-level client that improves the ergonomics of talking to a server
// implementing the Bayeux Protocol.
//
// The best way to create a high-level client is with `NewClient`. Provided a
// server address for the server you're using, you can create a client like so
//
// serverAddress := "https://localhost:8080/"
// client := gobayeux.NewClient(serverAddress)
//
// You can also register customer HTTP transports with your client
//
// transport := &http.Transport{
// DialContext: (&net.Dialer{
// Timeout: 3 * time.Second,
// KeepAlive: 10 * time.Second,
// }).DialContext,
// }
// client := gobayeux.NewClient(serverAddress, gobayeux.WithHTTPTransport(transport))
//
// You can subscribe to a Bayeux Channel with a chan to receive messages on
//
// recv := make(chan []gobayeux.Message)
// client.Subscribe("example-channel", recv)
//
// You can also register extensions that you'd like to use with the server
// by implementing the MessageExtender interface and then passing it to the
// client
//
// type Example struct {}
// func (e *Example) Registered(name string, client *gobayeux.BayeuxClient) {}
// func (e *Example) Unregistered() {}
// func (e *Example) Outgoing(m *gobayeux.Message) {
// switch m.Channel {
// case gobayeux.MetaHandshake:
// ext := m.GetExt(true)
// ext["example"] = true
// }
// }
// func (e *Example) Incoming(m *gobayeux.Message) {}
//
// e := &Example{}
// client.UseExtension(e)
package gobayeux