websocket

package
v0.0.0-...-440800f Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TextMessage denotes a text data message. The text message payload is
	// interpreted as UTF-8 encoded text data.
	TextMessage = 1

	// BinaryMessage denotes a binary data message.
	BinaryMessage = 2

	// CloseMessage denotes a close control message. The optional message
	// payload contains a numeric code and text. Use the FormatCloseMessage
	// function to format a close message payload.
	CloseMessage = 8

	// PingMessage denotes a ping control message. The optional message payload
	// is UTF-8 encoded text.
	PingMessage = 9

	// PongMessage denotes a ping control message. The optional message payload
	// is UTF-8 encoded text.
	PongMessage = 10
)

The message types are defined in RFC 6455, section 11.8.

Variables

View Source
var (
	// ErrMessageClose close control message
	ErrMessageClose = errors.New("close control message")
	// ErrMessageMaxRead continuation frame max read
	ErrMessageMaxRead = errors.New("continuation frame max read")
)
View Source
var (

	// ErrBadRequestMethod bad request method
	ErrBadRequestMethod = errors.New("bad method")
	// ErrNotWebSocket not websocket protocal
	ErrNotWebSocket = errors.New("not websocket protocol")
	// ErrBadWebSocketVersion bad websocket version
	ErrBadWebSocketVersion = errors.New("missing or bad WebSocket Version")
	// ErrChallengeResponse mismatch challenge response
	ErrChallengeResponse = errors.New("mismatch challenge/response")
)

Functions

This section is empty.

Types

type Conn

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

Conn represents a WebSocket connection.

func Upgrade

func Upgrade(rwc net.Conn, rr *bufio.Reader, wr *bufio.Writer, req *Request) (conn *Conn, err error)

Upgrade Switching Protocols

func (*Conn) Discard

func (c *Conn) Discard(n int) (int, error)

func (*Conn) Flush

func (c *Conn) Flush() error

Flush flush writer buffer

func (*Conn) Peek

func (c *Conn) Peek(n int) ([]byte, error)

func (*Conn) PeekByte

func (c *Conn) PeekByte() (uint8, error)

func (*Conn) PeekUint32

func (c *Conn) PeekUint32() (uint32, error)

func (*Conn) Read

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

func (*Conn) ReadMessage

func (c *Conn) ReadMessage() (op int, payload []byte, err error)

ReadMessage read a message.

func (*Conn) Write

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

func (*Conn) WriteBody

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

WriteBody write a message body.

func (*Conn) WriteHeader

func (c *Conn) WriteHeader(msgType int, length int) (err error)

WriteHeader write header frame.

func (*Conn) WriteMessage

func (c *Conn) WriteMessage(msgType int, msg []byte) (err error)

WriteMessage write a message by type.

type Request

type Request struct {
	Method     string
	RequestURI string
	Proto      string
	Host       string
	Header     http.Header
	// contains filtered or unexported fields
}

Request request.

func ReadRequest

func ReadRequest(r *bufio.Reader) (req *Request, err error)

ReadRequest reads and parses an incoming request from b.

Jump to

Keyboard shortcuts

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