websocket

package
v1.7.10 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 23 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = (&Options{
	OpCode:            ws.OpText,
	Dialer:            ws.DefaultDialer,
	Upgrader:          ws.DefaultHTTPUpgrader,
	ServeMux:          http.DefaultServeMux,
	Backlog:           128,
	NoDelay:           true,
	CompressLevel:     flate.BestSpeed,
	CompressThreshold: 512,
}).Apply()

DefaultOptions default websocket options

Functions

func New

func New() transport.Factory

New websocket transport factory

func WithOptions

func WithOptions(option *Options) transport.Option

WithOptions to wrap the websocket options

Types

type HTTPUpgrader added in v1.6.0

type HTTPUpgrader struct {
	Upgrader ws.HTTPUpgrader
	// contains filtered or unexported fields
}

func NewHTTPUpgrader added in v1.6.0

func NewHTTPUpgrader(engine netty.Bootstrap, option ...transport.Option) HTTPUpgrader

func (HTTPUpgrader) Upgrade added in v1.6.0

func (hu HTTPUpgrader) Upgrade(writer http.ResponseWriter, request *http.Request) (netty.Channel, error)

type Options

type Options struct {
	CertFile          string          `json:"certFile"`
	KeyFile           string          `json:"keyFile"`
	OpCode            ws.OpCode       `json:"opCode"`
	Routers           []string        `json:"routers"`
	CheckUTF8         bool            `json:"checkUTF8"`
	MaxFrameSize      int64           `json:"maxFrameSize"`
	ReadBufferSize    int             `json:"readBufferSize"`
	WriteBufferSize   int             `json:"writeBufferSize"`
	Backlog           int             `json:"backlog"`
	NoDelay           bool            `json:"nodelay"`
	CompressEnabled   bool            `json:"compressEnabled"`
	CompressLevel     int             `json:"compressLevel"`
	CompressThreshold int64           `json:"compressThreshold"`
	TLS               *tls.Config     `json:"-"`
	Dialer            ws.Dialer       `json:"-"`
	Upgrader          ws.HTTPUpgrader `json:"-"`
	ServeMux          *http.ServeMux  `json:"-"`
	// contains filtered or unexported fields
}

Options to define the websocket

func FromContext

func FromContext(ctx context.Context, def *Options) *Options

FromContext to unwrap the websocket options

func (*Options) Apply added in v1.6.1

func (o *Options) Apply() *Options

type Upgrader added in v1.6.0

type Upgrader interface {
	Upgrade(writer http.ResponseWriter, request *http.Request) (netty.Channel, error)
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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