Documentation
¶
Index ¶
- Constants
- func CheckOrigin(origins string) func(r *http.Request) bool
- func CloseWithReason(ws *websocket.Conn, code int, reason string)
- func IsCloseError(err error) bool
- func WebsocketHandler(subprotocols []string, headersExtractor server.HeadersExtractor, ...) http.Handler
- type Config
- type Connection
- type FrameType
- type SentFrame
Constants ¶
View Source
const ( // CloseNormalClosure indicates normal closure CloseNormalClosure = websocket.CloseNormalClosure // CloseInternalServerErr indicates closure because of internal error CloseInternalServerErr = websocket.CloseInternalServerErr // CloseAbnormalClosure indicates abnormal close CloseAbnormalClosure = websocket.CloseAbnormalClosure // CloseGoingAway indicates closing because of server shuts down or client disconnects CloseGoingAway = websocket.CloseGoingAway )
Variables ¶
This section is empty.
Functions ¶
func CloseWithReason ¶
CloseWithReason closes WebSocket connection with the specified close code and reason
func IsCloseError ¶
func WebsocketHandler ¶
func WebsocketHandler(subprotocols []string, headersExtractor server.HeadersExtractor, config *Config, sessionHandler sessionHandler) http.Handler
WebsocketHandler generate a new http handler for WebSocket connections
Types ¶
type Config ¶
type Config struct { ReadBufferSize int WriteBufferSize int MaxMessageSize int64 EnableCompression bool AllowedOrigins string }
Config contains WebSocket connection configuration.
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection is a WebSocket implementation of Connection
func NewConnection ¶
func NewConnection(conn *websocket.Conn) *Connection
func (Connection) Close ¶
func (ws Connection) Close(code int, reason string)
Close sends close frame with a given code and a reason
func (Connection) Read ¶
func (ws Connection) Read() ([]byte, error)
func (Connection) Write ¶
func (ws Connection) Write(msg []byte, deadline time.Time) error
Write writes a text message to a WebSocket
func (Connection) WriteBinary ¶
func (ws Connection) WriteBinary(msg []byte, deadline time.Time) error
WriteBinary writes a binary message to a WebSocket
Click to show internal directories.
Click to hide internal directories.