Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrRequestIllegal = errors.New("request data illegal")
ErrRequestIllegal describes error when data of the request is unaccepted.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct { Conn *websocket.Conn AfterReadFunc func(messageType int, r io.Reader) BeforeCloseFunc func() // contains filtered or unexported fields }
Conn wraps websocket.Conn with Conn. It defines to listen and read data from Conn.
type RegisterMessage ¶
RegisterMessage defines message struct client send after connection to the server.
type Server ¶
type Server struct { // Address for server to listen on Addr string // Path for websocket request, default "/ws". WSPath string // Path for send message, default "/send". SendPath string // Upgrader is for upgrade connection to websocket connection using // "github.com/gorilla/websocket". // // If Upgrader is nil, default upgrader will be used. Default upgrader is // set ReadBufferSize and WriteBufferSize to 1024, and CheckOrigin always // returns true. Upgrader *websocket.Upgrader // Check token if it's valid and return userID. If token is invalid, err // should not be nil. AuthToken func(token string) (userID string, err error) // Authorize send request. Message will be sent if it returns true, // otherwise the request will be discarded. Default nil and send request // will always be accepted. SendAuth func(r *http.Request) bool // contains filtered or unexported fields }
Server defines parameters for running websocket server.
func (*Server) ListenAndServe ¶
ListenAndServe listens on the TCP network address and handle websocket request.
Click to show internal directories.
Click to hide internal directories.