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 EncodeMessage(typ MessageType, msg interface{}) ([]byte, error)
- func Handler(res http.ResponseWriter, req *http.Request)
- func Listen() error
- func UpdatePost(id int64, key string, val interface{}, msg []byte) error
- type Client
- type ClientMap
- type MessageType
- type SyncID
Constants ¶
This section is empty.
Variables ¶
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.
func EncodeMessage ¶
func EncodeMessage(typ MessageType, msg interface{}) ([]byte, error)
EncodeMessage encodes a message for sending through websockets or writing to the replication log.
func Handler ¶
func Handler(res http.ResponseWriter, req *http.Request)
Handler is an http.HandleFunc that responds to new websocket connection requests.
Types ¶
type Client ¶
type Client struct { // Client identity information auth.Ident // 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 clients connected to this server instance
type MessageType ¶
type MessageType uint8
MessageType is the identifier code for websocket message types
const ( MessageInvalid MessageType = iota MessageInsertThread MessageInsertPost MessageAppend MessageBackspace MessageSplice MessageClosePost MessageLink MessageBacklink MessageCommand MessageInsertImage MessageSpoiler MessageDelete )
1 - 29 modify post model state
const ( // Update feeds MessageSynchronise MessageType = 30 + iota MessageReclaim MessageSwitchSync // Account management MessageRegister MessageLogin MessageAuthenticate MessageLogout MessageLogOutAll MessageChangePassword // Board administration MessageConfigServer MessageCreateBoard // Send new post ID to client MessagePostID // Concatenation of multiple websocket messages to reduce transport overhead MessageConcat )
>= 30 are miscelenious and do not write to post models