ORIONIS API REFERENCE

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

Translate the ASGI WebSocket protocol into normalized operations.

Method __init__ Retain callbacks and advertised WebSocket specification version.
Method _acceptHeaders Validate and encode handshake headers before sending any event.
Async Method _connectEvent 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 sendBytes Send one binary message and await server backpressure.
Async Method sendText Send one text message and await server backpressure.
Class Variable __slots__ Undocumented
Instance Variable _handshake_received Undocumented
Instance Variable _receive Undocumented
Instance Variable _scope Undocumented
Instance Variable _send Undocumented
Instance Variable _version Undocumented

Inherited from IWebSocketTransport:

Property supportsCloseDetails Declare whether custom close details can reach the wire.
def __init__(self, scope: dict, receive: Callable[[], Awaitable[dict]], send: Callable[[dict], Awaitable[None]]): (source)

Retain callbacks and advertised WebSocket specification version.

Parameters
scope:dictOriginal ASGI connection scope.
receive:CallableServer event reader.
send:CallableServer event writer.
Returns
NonePrepare the pending handshake.
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] | NoneUser supplied response headers.
Returns
list[tuple[bytes, bytes]]Encoded lowercase header pairs.
Raises
NotImplementedErrorIf the server predates ASGI HTTP 2.1.
ValueErrorIf a header violates the handshake header rules.
async def _connectEvent(self): (source)

Consume the server's initial handshake event once.

Returns
NoneValidate that the peer is awaiting acceptance.
Raises
WebSocketDisconnectedIf the peer disconnects before acceptance.
RuntimeErrorIf 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, optionalSubprotocol offered by the client.
headers:Mapping[str, str] | None, optionalAdditional headers supported since ASGI HTTP 2.1.
Returns
NoneAwait server acceptance.
Raises
ValueErrorIf the selected subprotocol was not offered.
WebSocketDisconnectedIf the peer disappears during acceptance.
async def close(self, code: int = 1000, reason: str = ''): (source)

Send a close event using fields supported by the advertised version.

Parameters
code:int, optionalValid WebSocket close code.
reason:str, optionalReason sent on servers supporting ASGI HTTP 2.3 or later.
Returns
NoneAwait the close event delivery.
Raises
WebSocketDisconnectedIf the peer closes before the event reaches the server.
async def receive(self) -> WebSocketMessage: (source)

Normalize one complete ASGI data or disconnect event.

Returns
WebSocketMessageThe payload or peer closure details.
Raises
RuntimeErrorIf the server supplies an invalid event or two payloads.
WebSocketDisconnectedIf a transport read raises an operating system error.
async def reject(self, status_code: int = 403): (source)

Deny the handshake with an HTTP status when the extension exists.

Parameters
status_code:int, optionalRejection status; servers without the extension always use 403.
Returns
NoneFinish the denial exchange.
Raises
WebSocketDisconnectedIf the peer closes while rejection is sent.
async def sendBytes(self, data: bytes): (source)

Send one binary message and await server backpressure.

Parameters
data:bytesBinary payload.
Returns
NoneFinish the transport write.
Raises
WebSocketDisconnectedIf the peer has closed the connection.
async def sendText(self, data: str): (source)

Send one text message and await server backpressure.

Parameters
data:strText payload.
Returns
NoneFinish the transport write.
Raises
WebSocketDisconnectedIf the peer has closed the connection.
_handshake_received: bool = (source)

Undocumented

_receive = (source)

Undocumented

Undocumented

Undocumented

_version = (source)

Undocumented