Documentation ¶
Overview ¶
Package websockets manages active websocket connections and messages received from and sent to them
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Clients = ClientMap{ // contains filtered or unexported fields }
Clients stores all synchronized websocket clients in a thread-safe map
Functions ¶
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 // 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 // Message from the client meant to invoke no operation. Mostly used as a // one way ping, because the JS Websocket API does not provide access to // pinging. MessageNOOP )
>= 30 are miscellaneous and do not write to post models