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 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__ |
Declare the instance attribute slots reserved by this class. |
| Instance Variable | _handshake |
Handshake received flag used by ASGIWebSocketTransport. |
| Instance Variable | _receive |
Server event reader. |
| Instance Variable | _scope |
Original ASGI connection scope. |
| Instance Variable | _send |
Server event writer. |
| Instance Variable | _version |
Version string advertised by the implementation. |
Inherited from IWebSocketTransport:
| Property | supports |
Declare whether custom close details can reach the wire. |
dict, receive: Callable[ [], Awaitable[ dict]], send: Callable[ [ dict], Awaitable[ None]]):
(source)
¶
Retain callbacks and advertised WebSocket specification version.
| Parameters | |
scope:dict | Original ASGI connection scope. |
receive:collections.abc.Callable | Server event reader. |
send:collections.abc.Callable | Server event writer. |
| Returns | |
None | Prepare the pending handshake. |
Mapping[ str, str] | None) -> list[ tuple[ bytes, bytes]]:
(source)
¶
Validate and encode handshake headers before sending any event.
| Parameters | |
headers:collections.abc.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 | |
orionis.http.WebSocketDisconnected | If the peer disconnects before acceptance. |
RuntimeError | If the server supplies an invalid initial event. |
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:collections.abc.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. |
orionis.http.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 | |
orionis.http.WebSocketDisconnected | If the peer closes before the event reaches the server. |
Normalize one complete ASGI data or disconnect event.
| Returns | |
orionis.http.WebSocketMessage | The payload or peer closure details. |
| Raises | |
RuntimeError | If the server supplies an invalid event or two payloads. |
orionis.http.WebSocketDisconnected | If a transport read raises an operating system error. |
Deny the handshake with an HTTP status when the extension exists.
| Parameters | |
statusint, optional | Rejection status; servers without the extension always use 403. |
| Returns | |
None | Finish the denial exchange. |
| Raises | |
orionis.http.WebSocketDisconnected | If the peer closes while rejection is sent. |
Send one binary message and await server backpressure.
| Parameters | |
data:bytes | Binary payload. |
| Returns | |
None | Finish the transport write. |
| Raises | |
orionis.http.WebSocketDisconnected | If the peer has closed the connection. |
Send one text message and await server backpressure.
| Parameters | |
data:str | Text payload. |
| Returns | |
None | Finish the transport write. |
| Raises | |
orionis.http.WebSocketDisconnected | If the peer has closed the connection. |