baml.ws.WebSocket
A WebSocket connection.
Signature
class baml.ws.WebSocketA WebSocket connection.
Source:<builtin>/baml/ns_ws/ws.bamlbytes 89–1819
Fields
_handle
$rust_typeInstance methods
Begin the closing handshake, sending code and reason to the peer.
This returns as soon as the close frame is queued. The connection ends
when the peer echoes it, which next reports as a CloseEvent.
Throws
baml.errors.InvalidArgumentifcodeis not one an endpoint may send (RFC 6455: 1000-1003, 1007-1013, 3000-3999, 4000-4999; not the undefined codes or the inferred-only 1004/1005/1006/1015), or ifreasonexceeds 123 bytes, the most a close frame can carry.
Block until the next frame arrives.
A text frame is a string and a binary frame a uint8array. Pings are
answered here automatically, and neither ping nor pong frames surface.
Once the connection ends — closed by either party, or dropped — this
returns the same CloseEvent on every call, so a receive loop
terminates on the first one rather than blocking forever.
Throws
baml.errors.Ioif the connection fails while receiving.
Send one frame: a string becomes a text frame, a uint8array a
binary one.
Throws
baml.errors.Ioif the connection is already closed, or the send fails.
Implementations
baml.Concrete for T
Source:<builtin>/baml/core.bamlbytes 747–779