websocket

package module
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChannelBinary = byte(websocket.BinaryMessage)
	ChannelText   = byte(websocket.TextMessage)
)

Variables

View Source
var (
	DefaultDialer   = &Dialer{}
	DefaultUpgrader = &Upgrader{
		CheckOrigin: func(r *http.Request) bool { return true },
	}
)

Functions

This section is empty.

Types

type Conn

type Conn struct {
	V *websocket.Conn
	// contains filtered or unexported fields
}

Conn wraps a *gorilla/websocket.Conn to fit the msg package framework. Only binary and text messages are handled.

func (*Conn) Close

func (x *Conn) Close() error

func (*Conn) Listen

func (x *Conn) Listen() (err error)

Listen routes incoming messages according to their type. If no target has been specified for a channel, the messages from that channel will be discarded. Returns on error, or when closed. In either case, the websocket is no longer usable. In particular, a chained ReaderTaker should not return an error when the connection should be kept alive.

An active Listen loop is necessary in order to drain incoming messages.

func (*Conn) ReaderChain

func (x *Conn) ReaderChain(ch byte, dst msg.ReaderTaker) error

Should not be called during an active Listen loop.

func (*Conn) Writer

func (x *Conn) Writer(ch byte) (msg.Writer, error)

Not concurrent safe.

type Dialer

type Dialer websocket.Dialer

func (*Dialer) Dial

func (x *Dialer) Dial(url string) (*Conn, error)

type Upgrader

type Upgrader websocket.Upgrader

func (*Upgrader) Upgrade

func (x *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request) (*Conn, error)

Jump to

Keyboard shortcuts

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