package
0.53.1
Repository: https://github.com/shulhan/share.git
Documentation: pkg.go.dev

# Packages

Package examples provide an example on how to use WebSocket server and client.

# Functions

NewBroadcast create a new message for broadcast by server encoded as JSON and wrapped in TEXT frame.
NewFrame create a single finished frame with specific operation code and optional payload.
NewFrameBin create a single binary data frame with optional payload.
NewFrameClose create control CLOSE frame.
NewFramePing create a masked PING control frame.
NewFramePong create a masked PONG control frame to be used by client.
NewFrameText create a single text data frame with optional payload.
NewServer create new WebSocket server.
Recv read packet from socket fd.
Send the packet through socket file descriptor fd.
Unpack websocket data protocol from raw bytes to one or more frames.

# Constants

List of valid context key.
List of valid context key.
List of valid context key.
List of valid operation code in frame.
List of valid operation code in frame.
List of valid operation code in frame.
%xB-F are reserved for further control frames.
List of valid operation code in frame.
List of valid operation code in frame.
List of valid operation code in frame.
List of valid operation code in frame.
%x3-7 are reserved for further non-control frames.
List of valid operation code in frame.
List of valid operation code in frame.
List of valid operation code in frame.
List of valid operation code in frame.
List of valid operation code in frame.
List of valid operation code in frame.
List of valid operation code in frame.
StatusBadGateway indicates that an endpoint (client) is terminating the connection because it has expected the server to negotiate one or more extension, but the server didn't return them in the response message of the WebSocket handshake.
StatusBadRequest indicates that an endpoint is terminating the connection due to a protocol error.
StatusForbidden indicates that an endpoint is terminating the connection because it has received a message that violates its policy.
StatusGone indicates that an endpoint is "going away", such as a server going down or a browser having navigated away from a page.
StatusInternalError indicates that a server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request.
StatusInvalidData indicates that an endpoint is terminating the connection because it has received data within a message that was not consistent with the type of the message (e.g., non-UTF-8 [RFC3629] data within a text message).
StatusNormal indicates a normal closure, meaning that the purpose for which the connection was established has been fulfilled.
StatusRequestEntityTooLarge indicates that an endpoint is terminating the connection because it has received a message that is too big for it to process.
StatusUnsupportedType indicates that an endpoint is terminating the connection because it has received a type of data it cannot accept (e.g., an endpoint that understands only text data MAY send this if it receives a binary message).

# Variables

List of errors.
ErrConnClosed define an error if client is not connected and try to send a message.
List of errors.
List of errors.
List of errors.
List of errors.
List of errors.
List of errors.
List of errors.
List of errors.
List of errors.
List of errors.
List of errors.
List of errors.
List of errors.
List of route error values.
List of route error values.
List of route error values.
List of errors.

# Structs

Client for WebSocket protocol.
ClientManager manage list of active websocket connections on server.
Frame represent a WebSocket data protocol.
Frames represent continuous (fragmented) frame.
Handshake contains the websocket HTTP handshake request.
Request define text payload format for client requesting resource on server.
Response contains the data that server send to client as a reply from Request or as broadcast from client subscription.
Server for websocket.
ServerOptions contain options to configure the WebSocket server.

# Type aliases

ClientHandler define a callback type for client to handle packet from server (either broadcast or from response of request) in the form of frame.
CloseCode represent the server close status.
ContextKey define a type for context.
HandlerAuthFn define server callback type to handle authentication request.
HandlerClientFn define server callback type to handle new client connection or removed client connection.
HandlerFrameFn define a server callback type to handle client request with single frame.
HandlerPayloadFn define server callback type to handle data frame from client.
HandlerStatusFn define server callback type to handle status request.
Opcode represent the websocket operation code.
RouteHandler is a function that will be called when registered method and target match with request.