Documentation ¶
Index ¶
Constants ¶
const ( // EventTypeWebP is used to signal what type of message we are sending over // the socket. EventTypeWebP = "webp" // EventTypeSchema is used to signal that the schema for a given app has // changed. EventTypeSchema = "schema" // EventTypeErr is used to signal there was an error encountered rendering // the WebP image. EventTypeErr = "error" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides a structure for incomming websocket requests so they can be tracked by a Fanout.
func (*Client) Quit ¶
func (c *Client) Quit()
Quit will close the connection and unregiseter it from the Fanout.
func (*Client) Send ¶
func (c *Client) Send(event WebsocketEvent)
Send is used to send a webp message to the client.
type Fanout ¶
type Fanout struct {
// contains filtered or unexported fields
}
Fanout provides a structure for broadcasting messages to registered clients when an update comes in on a go channel.
func NewFanout ¶
func NewFanout() *Fanout
NewFanout creates a new Fanout structure and runs the main loop.
func (*Fanout) Broadcast ¶
func (fo *Fanout) Broadcast(event WebsocketEvent)
Broadcast sends a message to all registered clients.
func (*Fanout) NewClient ¶
NewClient instantiates a client with a websocket connection. It spwans off go routines to send data to the client and send pings to ensure the client is still alive. We're passing a Fanout here so the client can unregister itself on error.
func (*Fanout) RegisterClient ¶
RegisterClient registers a client to include in broadcasts.
func (*Fanout) UnregisterClient ¶
UnregisterClient removes it from the broadcast.
type WebsocketEvent ¶
type WebsocketEvent struct { // Message is the contents of the message. This is a webp, base64 encoded. Message string `json:"message"` // Type is the type of message we are sending over the socket. Type string `json:"type"` }
WebsocketEvent is a structure used to send messages over the socket.