Versions in this module Expand all Collapse all v1 v1.0.1 Jun 24, 2023 Changes in this version + var DefaultBlockingModAsyncWrite = true + var DefaultBlockingModSendQueueInitSize = 4 + var DefaultBlockingModSendQueueMaxSize = 0 + var DefaultBlockingReadBufferSize = 1024 * 4 + var DefaultEngine = iohttp.NewEngine(iohttp.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(...) + func CloseCode(err error) int + func CloseReason(err error) string + type CloseError struct + Code int + Reason string + func (ce CloseError) Error() string + type Conn struct + func NewConn(u *Upgrader, c net.Conn, subprotocol string, remoteCompressionEnabled bool, ...) *Conn + func (c *Conn) BlockingModReadLoop(bufSize int) + func (c *Conn) Close() error + func (c *Conn) CloseAndClean(err error) + func (c *Conn) CloseWithError(err error) error + func (c *Conn) CompressionEnabled() bool + func (c *Conn) EnableCompression(enable bool) + func (c *Conn) EnableWriteCompression(enable bool) + func (c *Conn) IsAsyncWrite() bool + func (c *Conn) IsBlockingMod() bool + func (c *Conn) OnClose(h func(*Conn, error)) + func (c *Conn) OnDataFrame(h func(*Conn, MessageType, bool, []byte)) + func (c *Conn) OnMessage(h func(*Conn, MessageType, []byte)) + func (c *Conn) OnOpen(h func(*Conn)) + func (c *Conn) Read(p *iohttp.Parser, data []byte) error + func (c *Conn) Session() interface{} + func (c *Conn) SetCloseError(err error) + func (c *Conn) SetCloseHandler(h func(*Conn, int, string)) + func (c *Conn) SetPingHandler(h func(*Conn, string)) + func (c *Conn) SetPongHandler(h func(*Conn, string)) + func (c *Conn) SetSession(session interface{}) + func (c *Conn) Subprotocol() string + func (c *Conn) Write(data []byte) (int, error) + func (c *Conn) WriteClose(code int, reason string) 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 *iohttp.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 struct + BlockingModAsyncWrite bool + BlockingModReadBufferSize int + BlockingModSendQueueInitSize int + BlockingModSendQueueMaxSize int + CheckOrigin func(r *http.Request) bool + HandshakeTimeout time.Duration + Subprotocols []string + func NewUpgrader() *Upgrader + func (u *Upgrader) EnableCompression(enable bool) + func (u *Upgrader) OnClose(h func(*Conn, error)) + func (u *Upgrader) OnDataFrame(h func(*Conn, MessageType, bool, []byte)) + func (u *Upgrader) OnMessage(h func(*Conn, MessageType, []byte)) + func (u *Upgrader) OnOpen(h func(*Conn)) + func (u *Upgrader) SetCloseHandler(h func(*Conn, int, string)) + func (u *Upgrader) SetCompressionLevel(level int) error + func (u *Upgrader) SetPingHandler(h func(*Conn, string)) + func (u *Upgrader) SetPongHandler(h func(*Conn, string)) + func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header, ...) (*Conn, error) + func (u *Upgrader) UpgradeAndTransferConnToPoller(w http.ResponseWriter, r *http.Request, responseHeader http.Header) (*Conn, error)