Documentation ¶
Index ¶
- Constants
- Variables
- func FormatCloseMessage(closeCode int, text string) []byte
- func IsCloseError(err error, codes ...int) bool
- func IsUnexpectedCloseError(err error, expectedCodes ...int) bool
- func IsWebSocketUpgrade(header transports.Header) bool
- type BufferPool
- type CloseError
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) CloseHandler() func(code int, text string) error
- func (c *Conn) EnableWriteCompression(enable bool)
- func (c *Conn) Id() []byte
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) NetConn() net.Conn
- func (c *Conn) NextReader() (messageType int, r io.Reader, err error)
- func (c *Conn) NextWriter(messageType int) (io.WriteCloser, error)
- func (c *Conn) PingHandler() func(appData []byte) error
- func (c *Conn) PongHandler() func(appData []byte) error
- func (c *Conn) ReadMessage() (messageType int, p []byte, err error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) SetCloseHandler(h func(code int, text string) error)
- func (c *Conn) SetCompressionLevel(level int) error
- func (c *Conn) SetPingHandler(h func(appData []byte) error)
- func (c *Conn) SetPongHandler(h func(appData []byte) error)
- func (c *Conn) SetReadDeadline(t time.Time) error
- func (c *Conn) SetReadLimit(limit int64)
- func (c *Conn) SetWriteDeadline(t time.Time) error
- func (c *Conn) Subprotocol() string
- func (c *Conn) WriteControl(messageType int, data []byte, deadline time.Time) error
- func (c *Conn) WriteJSON(v interface{}) error
- func (c *Conn) WriteMessage(messageType int, data []byte) error
- func (c *Conn) WritePreparedMessage(pm *PreparedMessage) error
- func (c *Conn) WriteText(p []byte) error
- type Dialer
- type Handler
- type HandshakeError
- type PreparedMessage
- type Upgrader
Constants ¶
View Source
const ( CloseNormalClosure = 1000 CloseGoingAway = 1001 CloseProtocolError = 1002 CloseUnsupportedData = 1003 CloseNoStatusReceived = 1005 CloseAbnormalClosure = 1006 CloseInvalidFramePayloadData = 1007 ClosePolicyViolation = 1008 CloseMessageTooBig = 1009 CloseMandatoryExtension = 1010 CloseInternalServerErr = 1011 CloseServiceRestart = 1012 CloseTryAgainLater = 1013 CloseTLSHandshake = 1015 )
View Source
const ( TextMessage = 1 BinaryMessage = 2 CloseMessage = 8 PingMessage = 9 PongMessage = 10 )
Variables ¶
View Source
var ( ErrNilConn = errors.Warning("websocket: nil *Conn") ErrNilNetConn = errors.Warning("websocket: nil net.Conn") ErrCloseSent = errors.Warning("websocket: close sent") ErrReadLimit = errors.Warning("websocket: read limit exceeded") ErrBadHandshake = errors.Warning("websocket: bad handshake") )
View Source
var DefaultDialer = &Dialer{ Proxy: http.ProxyFromEnvironment, HandshakeTimeout: 45 * time.Second, }
Functions ¶
func FormatCloseMessage ¶
func IsCloseError ¶
func IsUnexpectedCloseError ¶
func IsWebSocketUpgrade ¶
func IsWebSocketUpgrade(header transports.Header) bool
Types ¶
type BufferPool ¶
type BufferPool interface { Get() interface{} Put(interface{}) }
type CloseError ¶
func (*CloseError) Error ¶
func (e *CloseError) Error() string
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func (*Conn) EnableWriteCompression ¶
func (*Conn) NextWriter ¶
func (c *Conn) NextWriter(messageType int) (io.WriteCloser, error)
func (*Conn) PingHandler ¶
func (*Conn) PongHandler ¶
func (*Conn) RemoteAddr ¶
func (*Conn) SetCompressionLevel ¶
func (*Conn) SetPingHandler ¶
func (*Conn) SetPongHandler ¶
func (*Conn) SetReadLimit ¶
func (*Conn) Subprotocol ¶
func (*Conn) WriteControl ¶
func (*Conn) WritePreparedMessage ¶
func (c *Conn) WritePreparedMessage(pm *PreparedMessage) error
type Dialer ¶
type Dialer struct { NetDial func(network, addr string) (net.Conn, error) NetDialContext func(ctx context.Context, network, addr string) (net.Conn, error) NetDialTLSContext func(ctx context.Context, network, addr string) (net.Conn, error) Proxy func(*http.Request) (*url.URL, error) TLSClientConfig *tls.Config HandshakeTimeout time.Duration ReadBufferSize int WriteBufferSize int WriteBufferPool BufferPool Subprotocols []string EnableCompression bool Jar http.CookieJar }
type HandshakeError ¶
type HandshakeError struct {
// contains filtered or unexported fields
}
func (HandshakeError) Error ¶
func (e HandshakeError) Error() string
type PreparedMessage ¶
type PreparedMessage struct {
// contains filtered or unexported fields
}
func NewPreparedMessage ¶
func NewPreparedMessage(messageType int, data []byte) (*PreparedMessage, error)
type Upgrader ¶
type Upgrader struct { HandshakeTimeout time.Duration ReadBufferSize int WriteBufferSize int WriteBufferPool BufferPool Subprotocols []string Error func(w transports.ResponseWriter, r transports.Request, status int, reason error) CheckOrigin func(r transports.Request) bool EnableCompression bool }
func (*Upgrader) Upgrade ¶
func (u *Upgrader) Upgrade(w transports.ResponseWriter, r transports.Request, handler Handler) error
Click to show internal directories.
Click to hide internal directories.