THE ORIONIS API
Build with clarity.
Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.
class WebSocket: (source)
Constructor: WebSocket(transport, adapter, params, max_message_size)
Own one server-independent connection with direct awaited messaging.
| Method | __aiter__ |
Iterate data messages until the peer disconnects. |
| Async Method | __anext__ |
Receive the next application message for asynchronous iteration. |
| Method | __init__ |
Bind a normalized transport and connection metadata. |
| Method | _disconnected |
Retain terminal metadata for later operation failures. |
| Async Method | _receive |
Receive data while translating disconnects to exceptions. |
| Method | _require |
Reject messaging outside the connected lifecycle state. |
| Async Method | accept |
Accept the pending handshake exactly once. |
| Async Method | close |
Close an accepted connection or reject a pending handshake once. |
| Async Method | receive |
Receive one immutable data or disconnect message. |
| Async Method | receive |
Receive one binary payload. |
| Async Method | receive |
Decode the next text or binary JSON message with msgspec. |
| Async Method | receive |
Receive one text payload. |
| Async Method | reject |
Reject the pending handshake once. |
| Method | route |
Return mutable connection-local route parameters. |
| Async Method | send |
Send text or bytes through a serialized, awaited transport write. |
| Async Method | send |
Send one binary message without copying the payload. |
| Async Method | send |
Encode a JSON value and send one UTF-8 text message. |
| Async Method | send |
Send one text message with natural backpressure. |
| Class Variable | __slots__ |
Undocumented |
| Instance Variable | _accepted |
Undocumented |
| Instance Variable | _adapter |
Undocumented |
| Instance Variable | _close |
Undocumented |
| Instance Variable | _close |
Undocumented |
| Instance Variable | _connection |
Undocumented |
| Instance Variable | _max |
Undocumented |
| Instance Variable | _params |
Undocumented |
| Instance Variable | _receive |
Undocumented |
| Instance Variable | _send |
Undocumented |
| Instance Variable | _state |
Undocumented |
| Instance Variable | _transport |
Undocumented |
| Property | accepted |
Report completed or interrupted acceptance. |
| Property | closed |
Report terminal connection closure. |
| Property | connection |
Return the explicit lifecycle state. |
| Property | headers |
Return handshake headers. |
| Property | path |
Return the handshake path. |
| Property | state |
Return connection-local application state. |
| Property | supports |
Report support for custom wire close details. |
Iterate data messages until the peer disconnects.
| Returns | |
WebSocket | This connection as a single-consumer async iterator. |
Receive the next application message for asynchronous iteration.
| Returns | |
WebSocketMessage | Next text or binary message. |
| Raises | |
StopAsyncIteration | If connection closure is observed. |
IWebSocketTransport, adapter: TransportAdapter, *, params: Mapping[ str, object] | None = None, max_message_size: int = _DEFAULT_MESSAGE_LIMIT):
(source)
¶
Bind a normalized transport and connection metadata.
| Parameters | |
transport:IWebSocketTransport | Server adapter implementing awaited network operations. |
adapter:TransportAdapter | Handshake metadata, including normalized proxy information. |
params:Mapping[str, object] | None, optional | Converted route parameters owned by this connection. |
maxint, optional | Positive maximum incoming message size in bytes. |
| Returns | |
None | Prepare a connection awaiting explicit acceptance. |
| Raises | |
ValueError | If the message size limit is not a positive integer. |
Receive data while translating disconnects to exceptions.
| Returns | |
WebSocketMessage | Text or binary data message. |
| Raises | |
WebSocketDisconnected | If the peer sends its terminal event. |
Reject messaging outside the connected lifecycle state.
| Returns | |
None | Validate that the handshake completed and closure has not started. |
| Raises | |
RuntimeError | If acceptance has not completed. |
WebSocketDisconnected | If the connection is closing or closed. |
str | None = None, headers: Mapping[ str, str] | None = None):
(source)
¶
Accept the pending handshake exactly once.
| Parameters | |
subprotocol:str | None, optional | Selected client-offered protocol, when supported by the server. |
headers:Mapping[str, str] | None, optional | Additional acceptance headers, when supported by the server. |
| Returns | |
None | Open the connection for messaging. |
| Raises | |
RuntimeError | If acceptance or closure already completed. |
WebSocketDisconnected | If the peer closes during acceptance. |
WebSocketStatus | int = WebSocketStatus.NORMAL_CLOSURE, reason: str = ''):
(source)
¶
Close an accepted connection or reject a pending handshake once.
| Parameters | |
code:WebSocketStatus | int, optional | Valid wire close code. |
reason:str, optional | Close reason bounded to 123 UTF-8 bytes. |
| Returns | |
None | Complete closure; repeated calls do nothing. |
| Raises | |
ValueError | If the code or reason is invalid. |
NotImplementedError | If the transport cannot transmit custom close details. |
Receive one immutable data or disconnect message.
| Returns | |
WebSocketMessage | Complete data or terminal peer event, delivered once. |
| Raises | |
RuntimeError | If unaccepted or another receiver is already active. |
WebSocketDisconnected | If closed, oversized, or the underlying transport disconnects. |
Receive one binary payload.
| Returns | |
bytes | Original binary message. |
| Raises | |
TypeError | If the next message contains text. |
WebSocketDisconnected | If the connection ends. |
Decode the next text or binary JSON message with msgspec.
| Returns | |
object | Decoded JSON value. |
| Raises | |
msgspec.DecodeError | If the payload is invalid JSON. |
WebSocketDisconnected | If the connection ends. |
Receive one text payload.
| Returns | |
str | Original text message. |
| Raises | |
TypeError | If the next message is binary. |
WebSocketDisconnected | If the connection ends. |
Reject the pending handshake once.
| Parameters | |
statusint, optional | HTTP error status when supported by the server. |
| Returns | |
None | Finish handshake denial; repeated calls do nothing. |
| Raises | |
RuntimeError | If acceptance was already attempted. |
ValueError | If the status is not an HTTP error code. |
Send text or bytes through a serialized, awaited transport write.
| Parameters | |
data:str | bytes | Complete message payload. |
| Returns | |
None | Deliver the message while preserving server backpressure. |
| Raises | |
TypeError | If data is neither text nor bytes. |
WebSocketDisconnected | If the peer closes before delivery. |
Report completed or interrupted acceptance.
| Returns | |
bool | Historical handshake indicator, retained after closure. |