Documentation
¶
Overview ¶
Package ws is a minimal, dependency-free RFC 6455 WebSocket server implementation, sufficient to carry Engine.IO/Socket.IO traffic. It supports the server-side opening handshake, fragmented data messages, and the control frames (ping/pong/close). Only what Socket.IO needs is implemented; it is not a general-purpose WebSocket library.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("ws: connection closed")
ErrClosed is returned once the connection has been closed.
Functions ¶
func IsWebSocketUpgrade ¶
IsWebSocketUpgrade reports whether r is a WebSocket upgrade request.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a WebSocket connection (server- or client-side).
func Dial ¶
Dial opens a client WebSocket connection to a ws:// or http:// URL. The returned Conn masks outgoing frames as required for clients.
func Upgrade ¶
Upgrade completes the server handshake and hijacks the connection, returning a *Conn ready for ReadMessage/WriteMessage.
func (*Conn) ReadMessage ¶
func (c *Conn) ReadMessage() (MessageType, []byte, error)
ReadMessage reads the next data message, transparently answering ping and close control frames. It reassembles fragmented messages.
func (*Conn) RemoteAddr ¶
RemoteAddr returns the underlying connection's remote address.
func (*Conn) WriteMessage ¶
func (c *Conn) WriteMessage(t MessageType, data []byte) error
WriteMessage writes a complete data message (single, unmasked frame).
type MessageType ¶
type MessageType int
MessageType distinguishes text and binary data messages.
const ( // TextMessage is a UTF-8 text message. TextMessage MessageType = iota // BinaryMessage is a binary message. BinaryMessage )