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 documentation
class ASGIWebSocketTransport(IWebSocketTransport): (source)
Constructor: ASGIWebSocketTransport(scope, receive, send)
Translate the ASGI WebSocket protocol into normalized operations.
| Method | __init__ |
Retain callbacks and advertised WebSocket specification version. |
| Method | _accept |
Validate and encode handshake headers before sending any event. |
| Async Method | _connect |
Consume the server's initial handshake event once. |
| Async Method | accept |
Accept using the server's supported handshake fields. |
| Async Method | close |
Send a close event using fields supported by the advertised version. |
| Async Method | receive |
Normalize one complete ASGI data or disconnect event. |
| Async Method | reject |
Deny the handshake with an HTTP status when the extension exists. |
| Async Method | send |
Send one binary message and await server backpressure. |
| Async Method | send |
Send one text message and await server backpressure. |
| Class Variable | __slots__ |
Undocumented |
| Instance Variable | _handshake |
Undocumented |
| Instance Variable | _receive |
Undocumented |
| Instance Variable | _scope |
Undocumented |
| Instance Variable | _send |
Undocumented |
| Instance Variable | _version |
Undocumented |
Inherited from IWebSocketTransport:
| Property | supports |
Declare whether custom close details can reach the wire. |
def _acceptHeaders(self, headers:
Mapping[ str, str] | None) -> list[ tuple[ bytes, bytes]]:
(source)
¶
Validate and encode handshake headers before sending any event.
| Parameters | |
headers:Mapping[str, str] | None | User supplied response headers. |
| Returns | |
list[tuple[bytes, bytes]] | Encoded lowercase header pairs. |
| Raises | |
NotImplementedError | If the server predates ASGI HTTP 2.1. |
ValueError | If a header violates the handshake header rules. |
Consume the server's initial handshake event once.
| Returns | |
None | Validate that the peer is awaiting acceptance. |
| Raises | |
WebSocketDisconnected | If the peer disconnects before acceptance. |
RuntimeError | If the server supplies an invalid initial event. |
async def accept(self, *, subprotocol:
str | None = None, headers: Mapping[ str, str] | None = None):
(source)
¶
Accept using the server's supported handshake fields.
| Parameters | |
subprotocol:str | None, optional | Subprotocol offered by the client. |
headers:Mapping[str, str] | None, optional | Additional headers supported since ASGI HTTP 2.1. |
| Returns | |
None | Await server acceptance. |
| Raises | |
ValueError | If the selected subprotocol was not offered. |
WebSocketDisconnected | If the peer disappears during acceptance. |
Send a close event using fields supported by the advertised version.
| Parameters | |
code:int, optional | Valid WebSocket close code. |
reason:str, optional | Reason sent on servers supporting ASGI HTTP 2.3 or later. |
| Returns | |
None | Await the close event delivery. |
| Raises | |
WebSocketDisconnected | If the peer closes before the event reaches the server. |
Normalize one complete ASGI data or disconnect event.
| Returns | |
WebSocketMessage | The payload or peer closure details. |
| Raises | |
RuntimeError | If the server supplies an invalid event or two payloads. |
WebSocketDisconnected | If a transport read raises an operating system error. |