const OP_CONTINUATION
pub const OP_CONTINUATION = 0Purpose
Constant OP_CONTINUATION, defining protocol or algorithm parameters.
#net/websocketWebSocket protocol implementation (RFC 6455). Supports frame encoding/decoding, masking/unmasking, handshake key negotiation, and high-level message read/write connections for both clients and servers.
const OP_CONTINUATIONpub const OP_CONTINUATION = 0Constant OP_CONTINUATION, defining protocol or algorithm parameters.
const OP_TEXTpub const OP_TEXT = 1Constant OP_TEXT, defining protocol or algorithm parameters.
const OP_BINARYpub const OP_BINARY = 2Constant OP_BINARY, defining protocol or algorithm parameters.
const OP_CLOSEpub const OP_CLOSE = 8Constant OP_CLOSE, defining protocol or algorithm parameters.
const OP_PINGpub const OP_PING = 9Constant OP_PING, defining protocol or algorithm parameters.
const OP_PONGpub const OP_PONG = 10Constant OP_PONG, defining protocol or algorithm parameters.
const STATUS_NORMALpub const STATUS_NORMAL = 1000Constant STATUS_NORMAL, defining protocol or algorithm parameters.
const STATUS_GOING_AWAYpub const STATUS_GOING_AWAY = 1001Constant STATUS_GOING_AWAY, defining protocol or algorithm parameters.
const STATUS_PROTOCOL_ERRORpub const STATUS_PROTOCOL_ERROR = 1002Constant STATUS_PROTOCOL_ERROR, defining protocol or algorithm parameters.
const STATUS_UNSUPPORTEDpub const STATUS_UNSUPPORTED = 1003Constant STATUS_UNSUPPORTED, defining protocol or algorithm parameters.
compute_accept_keypub fn compute_accept_key(challenge_key string) stringcompute_accept_key computes the Sec-WebSocket-Accept response header value from the client's Sec-WebSocket-Key challenge according to RFC 6455 §4.2.2.
challenge_key stringstring — result string
struct Framepub struct Frame {
pub fin bool
pub opcode int
pub masked bool
pub payload string
}Websocket Protocol data frame encapsulation.
fin boolopcode intmasked boolpayload stringencode_framepub fn encode_frame(fin bool, opcode int, payload &string, mask bool) stringencode_frame serializes a WebSocket data frame into wire bytes.
fin boolopcode intpayload &stringmask boolstring — result string
decode_framepub fn decode_frame(raw &string) Framedecode_frame parses a single WebSocket frame from a byte buffer. Throws on failure; handle the error or propagate it to the caller.
raw &stringFrame — a value of this type
struct Connpub struct Conn {
pub fd int
pub is_client bool
pub closed bool
}Conn represents an active WebSocket connection over an underlying socket.
fd intis_client boolclosed boolnew_connpub fn new_conn(fd int, is_client bool) ConnConstruct conn.
fd intis_client boolConn — a value of this type
($&Conn) write_messagepub fn (c $&Conn) write_message(opcode int, payload string) intOperation on $&Conn: write message. Throws on failure; handle the error or propagate it to the caller.
c $&ConnConn instance used by this call (exclusive borrow).opcode intpayload stringint — a value of this type
($&Conn) write_textpub fn (c $&Conn) write_text(text string) intOperation on $&Conn: write text. Throws on failure; handle the error or propagate it to the caller.
c $&ConnConn instance used by this call (exclusive borrow).text stringint — a value of this type
($&Conn) write_binarypub fn (c $&Conn) write_binary(data string) intOperation on $&Conn: write binary. Throws on failure; handle the error or propagate it to the caller.
c $&ConnConn instance used by this call (exclusive borrow).data stringint — a value of this type
($&Conn) write_pingpub fn (c $&Conn) write_ping(data string) intOperation on $&Conn: write ping. Throws on failure; handle the error or propagate it to the caller.
c $&ConnConn instance used by this call (exclusive borrow).data stringint — a value of this type
($&Conn) write_pongpub fn (c $&Conn) write_pong(data string) intOperation on $&Conn: write pong. Throws on failure; handle the error or propagate it to the caller.
c $&ConnConn instance used by this call (exclusive borrow).data stringint — a value of this type
($&Conn) closepub fn (c $&Conn) close(code int, reason string) intOperation on $&Conn: close the resource. Throws on failure; handle the error or propagate it to the caller.
c $&ConnConn instance used by this call (exclusive borrow).code intreason stringint — a value of this type
upgradepub fn upgrade(ctx http.Context) Connupgrade upgrades an HTTP server request to a WebSocket connection. It verifies the required headers, computes the Sec-WebSocket-Accept token, sends the HTTP 101 Switching Protocols response, and returns the Conn. Throws on failure; handle the error or propagate it to the caller.
ctx http.ContextConn — a value of this type