Versions in this module Expand all Collapse all v1 v1.3.13 May 10, 2023 Changes in this version + var DefaultBlockingModAsyncWrite = false + var DefaultBlockingReadBufferSize = 1024 * 4 + var DefaultEngine = nbhttp.NewEngine(nbhttp.Config{ ... }) + var ErrBadHandshake = errors.New("websocket: bad handshake") + var ErrControlMessageFragmented = errors.New("websocket: control messages must not be fragmented") + var ErrFragmentsShouldNotHaveBinaryOrTextOpcode = errors.New("websocket: fragments should not have opcode of text or binary") + var ErrInvalidCloseCode = errors.New("websocket: invalid close code") + var ErrInvalidCompression = errors.New("websocket: invalid compression negotiation") + var ErrInvalidControlFrame = errors.New("websocket: invalid control frame") + var ErrInvalidWriteCalling = errors.New("websocket: invalid write calling, should call WriteMessage instead") + var ErrMalformedURL = errors.New("malformed ws or wss URL") + var ErrMessageSendQuqueIsFull = errors.New("message send queue is full") + var ErrMessageTooLarge = errors.New("message exceeds the configured limit") + var ErrReserveBitSet = errors.New("websocket: reserved bit set it frame") + var ErrReservedOpcodeSet = errors.New("websocket: reserved opcode received") + var ErrUpgradeInvalidWebsocketVersion = errors.New(...) + var ErrUpgradeMethodIsGet = errors.New(...) + var ErrUpgradeMissingWebsocketKey = errors.New(...) + var ErrUpgradeNotHijacker = errors.New("websocket: response does not implement http.Hijacker") + var ErrUpgradeOriginNotAllowed = errors.New("websocket: request origin not allowed by Upgrader.CheckOrigin") + var ErrUpgradeTokenNotFound = errors.New(...) + var ErrUpgradeUnsupportedExtensions = errors.New(...) + type Conn struct + Engine *nbhttp.Engine + func NewConn(u *Upgrader, c net.Conn, subprotocol string, remoteCompressionEnabled bool, ...) *Conn + func (c *Conn) EnableWriteCompression(enable bool) + func (c *Conn) OnClose(h func(*Conn, error)) + func (c *Conn) Session() interface{} + func (c *Conn) SetCompressionLevel(level int) error + func (c *Conn) SetSession(session interface{}) + func (c *Conn) Subprotocol() string + func (c *Conn) Write(data []byte) (int, error) + func (c *Conn) WriteFrame(messageType MessageType, sendOpcode, fin bool, data []byte) error + func (c *Conn) WriteMessage(messageType MessageType, data []byte) error + type Dialer struct + Cancel context.CancelFunc + CheckRedirect func(req *http.Request, via []*http.Request) error + DialTimeout time.Duration + EnableCompression bool + Engine *nbhttp.Engine + Jar http.CookieJar + Proxy func(*http.Request) (*url.URL, error) + Subprotocols []string + TLSClientConfig *tls.Config + Upgrader *Upgrader + func (d *Dialer) Dial(urlStr string, requestHeader http.Header, v ...interface{}) (*Conn, *http.Response, error) + func (d *Dialer) DialContext(ctx context.Context, urlStr string, requestHeader http.Header, ...) (*Conn, *http.Response, error) + type MessageType int8 + const BinaryMessage + const CloseMessage + const FragmentMessage + const PingMessage + const PongMessage + const TextMessage + type Upgrader = WebsocketReader + func NewUpgrader() *Upgrader + type WebsocketReader struct + BlockingModAsyncWrite bool + BlockingModReadBufferSize int + CheckOrigin func(r *http.Request) bool + Engine *nbhttp.Engine + HandshakeTimeout time.Duration + KeepaliveTime time.Duration + MessageLengthLimit int64 + ReadLimit int64 + Subprotocols []string + func NewWebsocketReader() *WebsocketReader + func (wr *WebsocketReader) BlockingModReadLoop() + func (wr *WebsocketReader) BlockingModWriteLoop() + func (wr *WebsocketReader) Close(p *nbhttp.Parser, err error) + func (wr *WebsocketReader) CompressionEnabled() bool + func (wr *WebsocketReader) EnableCompression(enable bool) + func (wr *WebsocketReader) EnableWriteCompression(enable bool) + func (wr *WebsocketReader) OnClose(h func(*Conn, error)) + func (wr *WebsocketReader) OnDataFrame(h func(*Conn, MessageType, bool, []byte)) + func (wr *WebsocketReader) OnMessage(h func(*Conn, MessageType, []byte)) + func (wr *WebsocketReader) OnOpen(h func(*Conn)) + func (wr *WebsocketReader) Read(p *nbhttp.Parser, data []byte) error + func (wr *WebsocketReader) SetBlockingMod(blocking bool) + func (wr *WebsocketReader) SetCloseHandler(h func(*Conn, int, string)) + func (wr *WebsocketReader) SetCompressionLevel(level int) error + func (wr *WebsocketReader) SetConn(conn *Conn) + func (wr *WebsocketReader) SetPingHandler(h func(*Conn, string)) + func (wr *WebsocketReader) SetPongHandler(h func(*Conn, string)) + func (wr *WebsocketReader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header) (net.Conn, error)