Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidPacket = errors.New("ws: invalid packet")
View Source
var ErrUnknownHandler = errors.New("ws: unknown handler")
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct { Request *http.Request Values sync.Map // contains filtered or unexported fields }
Connection holds all data and websocket connection
func (*Connection) Context ¶
func (conn *Connection) Context() context.Context
type Hook ¶
type Hook func(conn *Connection)
Hook is function called before main loop or after connection was closed
type Request ¶
type Request struct { C *Connection `json:"-"` ID int64 Topic string Data json.RawMessage }
Request represents data sends from client to server
type WS ¶
type WS interface { // RegisterHandler register function for entered topic // note that handlerFn is interface{} but should be function (func(r *Request, optionalParameter string)) RegisterHandler(topic string, handlerFn interface{}) //AddPreHook appends pre main loop hook AddPreHook(hook Hook) //AddPostHook appends post request hook AddPostHook(hook Hook) ServeHTTP(w http.ResponseWriter, r *http.Request) }
Click to show internal directories.
Click to hide internal directories.