ReadonlyclosedResolves with the close code and reason once the peer's close frame arrives.
Closes the connection.
Optionalcode: number
Optional RFC 6455 close code (e.g. 1000).
Optionalreason: string
Optional human-readable close reason.
Sends a message to the peer.
A string for a text frame, or bytes for a binary frame.
Serializes a value to JSON and sends it as a text frame.
The value is JSON.stringify-ed and sent with send.
The value to serialize and send.
A live WebSocket connection.
Async-iterate it to receive messages in arrival order; the iteration ends when the peer closes the socket. It is an
AsyncDisposable, soawait usingcloses it on scope exit.Since
1.0.0
Example