wslisten

package
v0.0.0-...-2cf227b Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2021 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const BinaryFormat = websocket.MessageBinary
View Source
const DefaultAcceptTimeout = 3 * time.Second
View Source
const TextFormat = websocket.MessageText

Variables

This section is empty.

Functions

This section is empty.

Types

type Format

type Format = websocket.MessageType

type Listener

type Listener struct {
	AcceptTimeout time.Duration // respond to HTTP requests if Accept not called.
	DefaultFormat Format        // Default write format; initialized to binary.
	// contains filtered or unexported fields
}

func ListenWS

func ListenWS() *Listener

ListenWS returns a websocket listener; This satisfies net.Listener in order to Accept, and satisfies http.Handler to serve the websocket.

func (*Listener) Accept

func (ln *Listener) Accept() (net.Conn, error)

Accept waits for and returns the next connection to the listener.

func (*Listener) Addr

func (ln *Listener) Addr() net.Addr

Addr returns the listener's network address.

func (*Listener) Close

func (ln *Listener) Close() error

Close closes the listener. Any blocked Accept operations will be unblocked and return errors.

func (*Listener) ServeHTTP

func (ln *Listener) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves the HTTP request and initiates a websocket, which is then returned by Accept.

Jump to

Keyboard shortcuts

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