ws

package
Version: v0.0.0-...-f10b52b Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// OptionDomains is option's domain
	OptionDomains = append(transport.OptionDomains, "ws")
	// Options for websocket
	Options = wsOptions{
		ReadBufferSize:  options.NewIntOption(4 * 1024),
		WriteBufferSize: options.NewIntOption(4 * 1024),
		Listener: listenerOptions{
			CheckOrigin:    options.NewBoolOption(false),
			OriginChecker:  options.NewAnyOption(noCheckOrigin),
			ExternalListen: options.NewBoolOption(false),
			PendingSize:    options.NewIntOption(16),
		},
	}
)
View Source
var (
	// RwTransport is a transport.Transport for Websocket, using ReadWriter.
	RwTransport = &wsTran{scheme: "ws.rw", isRw: true}
	// SrTransport is a transport.Transport for Websocket, using SendReceiver+ReadWriter.
	SrTransport = &wsTran{scheme: "ws.sr", isSr: true}
)

Functions

This section is empty.

Types

type CheckOriginFunc

type CheckOriginFunc func(r *http.Request) bool

CheckOriginFunc check request origin

type Listener

type Listener struct {
	URL *url.URL

	*http.ServeMux

	sync.Mutex
	// contains filtered or unexported fields
}

Listener websocket listener, exported for add handler or self serving

func (*Listener) Accept

func (l *Listener) Accept(opts options.Options) (transport.Connection, error)

Accept start accept

func (*Listener) Close

func (l *Listener) Close() error

Close stop listen

func (*Listener) Listen

func (l *Listener) Listen(opts options.Options) (err error)

Listen start listen

func (*Listener) ServeHTTP

func (l *Listener) ServeHTTP(resp http.ResponseWriter, req *http.Request)

Source Files

Jump to

Keyboard shortcuts

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