Documentation ¶
Overview ¶
Websocket-Hub is heavily derived from Gary Burd's example chat service, and much of this is copyright Gary Burd, used under the Apache License, Version 2.0 ( https://github.com/garyburd/go-websocket#license )
The remainder is copyright 2013 James Pirruccello. The entire work is offered under the Apache License, Version 2.0.
Websocket-Hub is heavily derived from Gary Burd's example chat service, and much of this is copyright Gary Burd, used under the Apache License, Version 2.0 ( https://github.com/garyburd/go-websocket#license )
The remainder is copyright 2013 James Pirruccello. The entire work is offered under the Apache License, Version 2.0.
Websocket-Hub is heavily derived from Gary Burd's example chat service, and much of this is copyright Gary Burd, used under the Apache License, Version 2.0 ( https://github.com/garyburd/go-websocket#license )
The remainder is copyright 2013 James Pirruccello. The entire work is offered under the Apache License, Version 2.0.
Index ¶
- func BroadcastAll(input []byte)
- func GetHub(id string) *hub
- func Initialize(writeWait, readWait, pingPeriod time.Duration, ...)
- func Launch(ws *websocket.Conn, id string)
- func Multicast(message []byte, ids []string)
- func NewConnection(ws *websocket.Conn, send chan []byte) *connection
- func Packetize(event string, data interface{}) ([]byte, error)
- type Packet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BroadcastAll ¶
func BroadcastAll(input []byte)
BroadcastAll sends a message to every client on every hub
func GetHub ¶
func GetHub(id string) *hub
GetHub retrieves the hub with a given ID from the hubMap. If no such hub exists, it creates it.
func Initialize ¶
func Launch ¶
TODO(james): When registering the handler, pull out the ID that they registered on. That will be the channel ID, which determines which hub they register upon. Each hub will exist as a separate goroutine. Thus, each page will have a different non-blocking hub, but all messages on a given page will be in order. TODO(james): When sending new data over the socket, look up all parent IDs in an ancestry cache; if that's empty then check DB. Finally, send the data to anyone registered to any ancestor channels. Launch handles all transactions over a websocket connection for a given hub
func Multicast ¶
Multicast sends a message to all hubs listed in []ids. If no such hub exists, nothing happens.