Documentation
¶
Overview ¶
Package websockets manages active websocket connections and messages received from and sent to them.
Index ¶
- Variables
- func CheckOrigin(req *http.Request) bool
- func Handler(res http.ResponseWriter, req *http.Request)
- type Client
- type ClientMap
- func (c *ClientMap) Add(cl *Client, syncID string)
- func (c *ClientMap) ChangeSync(clientID, syncID string)
- func (c *ClientMap) Clear()
- func (c *ClientMap) CountByIP() int
- func (c *ClientMap) Get(id string) (*Client, error)
- func (c *ClientMap) Has(id string) bool
- func (c *ClientMap) Remove(id string)
- func (c *ClientMap) SendAll(msg []byte)
Constants ¶
This section is empty.
Variables ¶
View Source
var Clients = ClientMap{ // contains filtered or unexported fields }
Clients stores all synchronised websocket clients in a theread-safe map
Functions ¶
func CheckOrigin ¶
CheckOrigin asserts the client matches the origin specified by the server or has none.
Types ¶
type Client ¶
type Client struct { ID string util.AtomicCloser // Send thread-safely sends a message to the websocket client Send chan []byte // AllocateImage receives Image structs from the thumbnailer for allocation // by the client AllocateImage chan types.Image // contains filtered or unexported fields }
Client stores and manages a websocket-connected remote client and its interaction with the server and database
type ClientMap ¶
ClientMap is a thread-safe store for all connected clients. You also perform multiclient message dispatches etc., by calling its methods.
func (*ClientMap) ChangeSync ¶
ChangeSync changes the thread or board ID the client is synchronised to
func (*ClientMap) CountByIP ¶
CountByIP returns the number of unique IPs synchronised with the server
Click to show internal directories.
Click to hide internal directories.