ws

package
v0.0.0-...-d761a6e Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpText   = 1
	OpBinary = 2
	OpClose  = 8
	OpPing   = 9
	OpPong   = 10
)

WebSocket frame opcodes

View Source
const (
	CloseStatusNoStatusReceived uint16 = 1005
	CloseStatusProtocolError    uint16 = 1002
)

WebSocket connection close status codes. https://www.rfc-editor.org/rfc/rfc6455#section-11.7

Variables

View Source
var (
	ErrProtocolError    = errors.New("protocol error")
	ErrConnectionClosed = errors.New("connection has been closed")
)
View Source
var (
	ErrUpgradeFailed = errors.New("failed to upgrade to the WebSocket protocol")
)

Functions

This section is empty.

Types

type Conn

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

Conn represents a WebSocket connection.

func (*Conn) Close

func (c *Conn) Close()

Close closes the WebSocket's TCP connection.

func (*Conn) ReadMessage

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

ReadMessage returns payload from inoming WebSocket frame.

func (*Conn) WriteMessage

func (c *Conn) WriteMessage(opcode uint8, m []byte) error

WriteMessage sends message to the client.

type Extension

type Extension struct {
	Token  string
	Params []string
}

type Upgrader

type Upgrader struct {
	// CheckOrigin returns boolean indicating if the origin is acceptable by the server.
	CheckOrigin func(r *http.Request) bool
	Protocol    string
	// RW buffer sizes
	ReadBufferSize  int
	WriteBufferSize int
	// Negotiate permessage-deflate extension
	Compress bool
}

func (*Upgrader) Upgrade

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

Upgrade upgrades the HTTP connection to use the WebSocket protocol.

Jump to

Keyboard shortcuts

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