websocket

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContinuationFrame represents a WebSocket continuation frame.
	ContinuationFrame = 0x0
	// TextFrame represents a WebSocket text frame.
	TextFrame = 0x1
	// BinaryFrame represents a WebSocket binary frame.
	BinaryFrame = 0x2
	// CloseFrame represents a WebSocket close frame.
	CloseFrame = 0x8
	// PingFrame represents a WebSocket ping frame.
	PingFrame = 0x9
	// PongFrame represents a WebSocket pong frame.
	PongFrame = 0xA
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

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

Conn represents a WebSocket connection.

func Dial

func Dial(network, address, path string, config *tls.Config) (*Conn, error)

Dial opens a new client connection to a WebSocket.

func Upgrade

func Upgrade(conn net.Conn, config *tls.Config) (*Conn, error)

Upgrade upgrades the net.Conn to the WebSocket protocol.

func UpgradeHTTP

func UpgradeHTTP(w http.ResponseWriter, r *http.Request) (*Conn, error)

UpgradeHTTP upgrades the HTTP server connection to the WebSocket protocol.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the connection.

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

LocalAddr returns the local network address. The Addr returned is shared by all invocations of LocalAddr, so do not modify it.

func (*Conn) Read

func (c *Conn) Read(b []byte) (n int, err error)

Read implements the net.Conn Read method.

func (*Conn) ReadMessage

func (c *Conn) ReadMessage(buf []byte) (p []byte, err error)

ReadMessage reads single message from ws.

func (*Conn) ReadTextMessage

func (c *Conn) ReadTextMessage() (p string, err error)

ReadTextMessage reads single text message from ws.

func (*Conn) ReceiveMessage

func (c *Conn) ReceiveMessage(v interface{}) (err error)

ReceiveMessage receives single frame from ws, unmarshaled and stores in v.

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

RemoteAddr returns the remote network address. The Addr returned is shared by all invocations of RemoteAddr, so do not modify it.

func (*Conn) SendMessage

func (c *Conn) SendMessage(v interface{}) (err error)

SendMessage sends v marshaled as single frame to ws.

func (*Conn) SetConcurrency

func (c *Conn) SetConcurrency(concurrency func() int)

SetConcurrency sets a callback func concurrency for writer.

func (*Conn) SetDeadline

func (c *Conn) SetDeadline(t time.Time) error

SetDeadline implements the Conn SetDeadline method.

func (*Conn) SetReadDeadline

func (c *Conn) SetReadDeadline(t time.Time) error

SetReadDeadline implements the Conn SetReadDeadline method.

func (*Conn) SetWriteDeadline

func (c *Conn) SetWriteDeadline(t time.Time) error

SetWriteDeadline implements the Conn SetWriteDeadline method.

func (*Conn) Write

func (c *Conn) Write(b []byte) (n int, err error)

Write implements the net.Conn Write method.

func (*Conn) WriteMessage

func (c *Conn) WriteMessage(b []byte) (err error)

WriteMessage writes single message to ws.

func (*Conn) WriteTextMessage

func (c *Conn) WriteTextMessage(b string) (err error)

WriteTextMessage writes single text message to ws.

type Handler

type Handler func(*Conn)

Handler represents a http.Handler.

func (Handler) ServeHTTP

func (handler Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface for a WebSocket

Jump to

Keyboard shortcuts

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