websocket

package
v0.0.0-...-bdc7756 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TextMessage   byte = 1
	BinaryMessage byte = 2
	CloseMessage  byte = 8
	PingMessage   byte = 9
	PongMessage   byte = 10
)

Variables

View Source
var (
	ErrControlTooLong    = errors.New("control message too long")
	ErrRSVNotSupport     = errors.New("reserved bit not support")
	ErrPayloadError      = errors.New("payload length error")
	ErrControlFragmented = errors.New("control message can not be fragmented")
	ErrNotTCPConn        = errors.New("not a tcp connection")
	ErrWriteError        = errors.New("write error")
)
View Source
var (
	ErrInvalidMethod     = errors.New("Only GET Supported")
	ErrInvalidVersion    = errors.New("Sec-Websocket-Version: 13")
	ErrInvalidUpgrade    = errors.New("Can \"Upgrade\" only to \"WebSocket\"")
	ErrInvalidConnection = errors.New("\"Connection\" must be \"Upgrade\"")
	ErrMissingKey        = errors.New("Missing Key")
	ErrHijacker          = errors.New("Not implement http.Hijacker")
	ErrNoEmptyConn       = errors.New("Conn ReadBuf must be empty")
)
View Source
var (
	ErrBadHandshake = errors.New("bad handshake")
)

Functions

func HandleCloseFrame

func HandleCloseFrame(buf []byte) (int16, string, error)

Types

type Conn

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

func NewClient

func NewClient(netConn net.Conn, u *url.URL, requestHeader http.Header) (c *Conn, response *http.Response, err error)

func NewConn

func NewConn(conn net.Conn, isServer bool) *Conn

func Upgrade

func Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header) (*Conn, error)

func (*Conn) Close

func (c *Conn) Close() error

close socket, not send websocket close message

func (*Conn) LocalAddr

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

func (*Conn) Ping

func (c *Conn) Ping(message []byte) error

func (*Conn) Pong

func (c *Conn) Pong(message []byte) error

func (*Conn) Read

func (c *Conn) Read() (messageType byte, message []byte, err error)

func (*Conn) ReadMessage

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

func (*Conn) RemoteAddr

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

func (*Conn) SetReadBuffer

func (c *Conn) SetReadBuffer(bytes int) error

func (*Conn) SetReadDeadline

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

func (*Conn) SetWriteBuffer

func (c *Conn) SetWriteBuffer(bytes int) error

func (*Conn) SetWriteDeadline

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

func (*Conn) Write

func (c *Conn) Write(message []byte, binary bool) error

func (*Conn) WriteBinary

func (c *Conn) WriteBinary(message []byte) error

write binary message

func (*Conn) WriteMessage

func (c *Conn) WriteMessage(messageType byte, message []byte) error

func (*Conn) WriteString

func (c *Conn) WriteString(message []byte) error

write utf-8 text message

Jump to

Keyboard shortcuts

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