good morning!!!!

Skip to content
Snippets Groups Projects
doc.go 1.96 KiB
Newer Older
// +build !js

// Package websocket is a minimal and idiomatic implementation of the WebSocket protocol.
Anmol Sethi's avatar
Anmol Sethi committed
//
Anmol Sethi's avatar
Anmol Sethi committed
// https://tools.ietf.org/html/rfc6455
Anmol Sethi's avatar
Anmol Sethi committed
//
Anmol Sethi's avatar
Anmol Sethi committed
// Conn, Dial, and Accept are the main entrypoints into this package. Use Dial to dial
// a WebSocket server, Accept to accept a WebSocket client dial and then Conn to interact
// with the resulting WebSocket connections.
Anmol Sethi's avatar
Anmol Sethi committed
//
// The examples are the best way to understand how to correctly use the library.
// The wsjson and wspb subpackages contain helpers for JSON and ProtoBuf messages.
Anmol Sethi's avatar
Anmol Sethi committed
//
Anmol Sethi's avatar
Anmol Sethi committed
// See https://nhooyr.io/websocket for more overview docs and a
Anmol Sethi's avatar
Anmol Sethi committed
// comparison with existing implementations.
//
Anmol Sethi's avatar
Anmol Sethi committed
// Use the errors.As function new in Go 1.13 to check for websocket.CloseError.
// See the CloseError example.
Anmol Sethi's avatar
Anmol Sethi committed
//
// WASM
//
// The client side fully supports compiling to WASM.
// It wraps the WebSocket browser API.
Anmol Sethi's avatar
Anmol Sethi committed
//
Anmol Sethi's avatar
Anmol Sethi committed
// See https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
//
// Thus the unsupported features (not compiled in) for WASM are:
Anmol Sethi's avatar
Anmol Sethi committed
//  - Accept and AcceptOptions
//  - Conn.Ping
//  - HTTPClient and HTTPHeader fields in DialOptions
Anmol Sethi's avatar
Anmol Sethi committed
//
// The *http.Response returned by Dial will always either be nil or &http.Response{} as
// we do not have access to the handshake response in the browser.
//
// The Writer method on the Conn buffers everything in memory and then sends it as a message
// when the writer is closed.
//
// The Reader method also reads the entire response and then returns a reader that
// reads from the byte slice.
//
// SetReadLimit cannot actually limit the number of bytes read from the connection so instead
// when a message beyond the limit is fully read, it throws an error.
//
Anmol Sethi's avatar
Anmol Sethi committed
// Writes are also always async so the passed context is no-op.
//
// Everything else is fully supported. This includes the wsjson and wspb helper packages.
//
// Once https://github.com/gopherjs/gopherjs/issues/929 is closed, GopherJS should be supported
// as well.
package websocket // import "nhooyr.io/websocket"