websocket

package
v0.0.0-...-b1b21d8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2023 License: LGPL-3.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetClientHeaders

func SetClientHeaders(headers http.Header, options ...Option)

Types

type CompressionMode

type CompressionMode = websocket.CompressionMode
const (

	// MessageText is for UTF-8 encoded text messages like JSON.
	MessageText websocket.MessageType = websocket.MessageText
	// MessageBinary is for binary messages like protobufs.
	MessageBinary websocket.MessageType = websocket.MessageBinary

	CompressionContextTakeover   CompressionMode = websocket.CompressionContextTakeover
	CompressionDisabled          CompressionMode = websocket.CompressionDisabled
	CompressionNoContextTakeover CompressionMode = websocket.CompressionNoContextTakeover
)

type CompressionOptions

type CompressionOptions = compressionOptions

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

func NewClientConn

func NewClientConn(resp *http.Response, options ...Option) (*Conn, error)

func NewConn

func NewConn(conn io.ReadWriteCloser, client bool, options ...Option) *Conn

func NewServerConn

func NewServerConn(w http.ResponseWriter, r *http.Request, options ...Option) (_ *Conn, err error)

func (*Conn) Close

func (obj *Conn) Close(reasons ...string) error

func (*Conn) Conn

func (obj *Conn) Conn() *websocket.Conn

func (*Conn) Option

func (obj *Conn) Option() Option

func (*Conn) Ping

func (obj *Conn) Ping(ctx context.Context) error

func (*Conn) Read

func (obj *Conn) Read(p []byte) (n int, err error)

func (*Conn) Recv

func (obj *Conn) Recv(ctx context.Context) (MessageType, []byte, error)

func (*Conn) RecvJson

func (obj *Conn) RecvJson(ctx context.Context, v any) error

func (*Conn) Rwc

func (obj *Conn) Rwc() io.ReadWriteCloser

func (*Conn) Send

func (obj *Conn) Send(ctx context.Context, typ MessageType, p any) error

func (*Conn) SendJson

func (obj *Conn) SendJson(ctx context.Context, v any) error

func (*Conn) SetReadLimit

func (obj *Conn) SetReadLimit(n int64)

func (*Conn) Write

func (obj *Conn) Write(p []byte) (n int, err error)

type MessageType

type MessageType = websocket.MessageType

type Option

type Option struct {
	Subprotocols         []string        // Subprotocols lists the WebSocket subprotocols to negotiate with the server.
	CompressionMode      CompressionMode // CompressionMode controls the compression mode.
	CompressionThreshold int             // CompressionThreshold controls the minimum size of a message before compression is applied ,Defaults to 512 bytes for CompressionNoContextTakeover and 128 bytes for CompressionContextTakeover.
	CompressionOptions   *compressionOptions
}

func GetHeaderOption

func GetHeaderOption(header http.Header, client bool) Option

func (*Option) Extensions

func (obj *Option) Extensions() string

func (*Option) Init

func (obj *Option) Init(client bool)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL