Documentation ¶
Index ¶
- type Config
- type Frame
- type HTTPHandler
- type Message
- type WebSocket
- func (ws *WebSocket) ReadFrame() (frame Frame, err error)
- func (ws *WebSocket) ReadMessage() (message Message, err error)
- func (ws *WebSocket) Request() *http.Request
- func (ws *WebSocket) WriteFrame(opcode byte, payload []byte) (err error)
- func (ws *WebSocket) WriteMessage(opcode byte, payload []byte) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
Settings for potential WebSocket connections. Subprotocols is a list of supported subprotocols as in RFC 6455 section 1.9. When answering client requests, the first of the client's requests subprotocols that is also in this list (if any) will be used as the subprotocol for the connection. MaxMessageSize is a limit on buffering messages.
type Frame ¶
Representation of a WebSocket frame. The Payload is always without masking.
type HTTPHandler ¶
An implementation of http.Handler with a Config. The ServeHTTP function calls Callback assuming WebSocket HTTP negotiation is successful.
func (*HTTPHandler) ServeHTTP ¶
func (handler *HTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
Implements the http.Handler interface.
type Message ¶
Representation of a WebSocket message. The Payload is always without masking.
type WebSocket ¶
type WebSocket struct { // Conn and ReadWriter from http.ResponseWriter.Hijack. Conn net.Conn Bufrw *bufio.ReadWriter // Whether we are a client or a server has implications for masking. IsClient bool // Set from a parent Config. MaxMessageSize int // The single selected subprotocol after negotiation, or "". Subprotocol string // contains filtered or unexported fields }
A WebSocket connection after hijacking from HTTP.
func (*WebSocket) ReadFrame ¶
Read a single frame from the WebSocket.
func (*WebSocket) ReadMessage ¶
Read a single message from the WebSocket. Multiple fragmented frames are combined into a single message before being returned. Non-control messages may be interrupted by control frames. The control frames are returned as individual messages before the message that they interrupt.
func (*WebSocket) WriteFrame ¶
Write a single frame to the WebSocket stream. Destructively masks payload in place if ws.IsClient. Frames are always unfragmented.