Vuer

vuer.client

Vuer Client - Connect to a Vuer server and send/receive events.

Example usage::

import asyncio from vuer import VuerClient from vuer.events import ClientEvent

class MyEvent(ClientEvent): etype = "MY_EVENT"

async def main(): async with VuerClient(URI="ws://localhost:8012") as client:

Fire-and-forget with @ syntax (no await needed)

client.send @ MyEvent(value={"key": "value"})

Awaitable with parentheses

await client.send(MyEvent(value={"data": 123}))

Receive events from the server

async for event in client: print(f"Received: {event}")

asyncio.run(main())

Configuration via environment variables: VUER_CLIENT_URI: WebSocket URI to connect to (default ws://localhost:8012) WEBSOCKET_MAX_SIZE: Maximum WebSocket message size in bytes (default 256MB)

AsyncAt

python
class AsyncAt

Source

Wrapper to support both @ syntax (fire-and-forget) and await for async operations.

AsyncAt.init

python
def __init__(self, coro_fn)

Source

VuerClient

python
class VuerClient

Source

Client for connecting to a Vuer server.

Supports sending ClientEvents and receiving ServerEvents via websocket.

Example::

async with VuerClient(URI="ws://localhost:8012") as client:

Using @ syntax (fire and forget)

client.send @ ClientEvent(etype="CUSTOM", value="hello")

Using await

await client.send(ClientEvent(etype="CUSTOM", value="hello"))

event = await client.recv() print(event)

Configuration (via constructor or environment variables): URI: WebSocket URI to connect to (env: VUER_CLIENT_URI, default ws://localhost:8012). WEBSOCKET_MAX_SIZE: Maximum WebSocket message size (env: WEBSOCKET_MAX_SIZE, default 256MB).

python
URI: str = EnvVar @ 'VUER_CLIENT_URI' | 'ws://localhost:8012'
python
WEBSOCKET_MAX_SIZE: int = EnvVar @ 'WEBSOCKET_MAX_SIZE' | 2 ** 28

VuerClient.init

python
def __init__(self, URI: str=None, WEBSOCKET_MAX_SIZE: int=None)

Source

Initialize the Vuer client.

:param URI: WebSocket URI to connect to (e.g., "ws://localhost:8012") :param WEBSOCKET_MAX_SIZE: Maximum websocket message size in bytes (default 256MB)

VuerClient.connect

python
async def connect(self) -> 'VuerClient'

Source

Connect to the Vuer server.

:return: Self for chaining

VuerClient.close

python
async def close(self) -> None

Source

Close the connection.

VuerClient.connected

python
def connected(self) -> bool

Source

Check if client is connected.

VuerClient.send

python
def send(self) -> AsyncAt

Source

Send a ClientEvent to the Vuer server.

Supports both @ syntax and await::

Fire and forget with @ syntax

client.send @ ClientEvent(etype="CUSTOM", value="data")

Awaitable

await client.send(ClientEvent(etype="CUSTOM", value="data"))

:return: AsyncAt wrapper supporting @ and await

VuerClient.recv

python
async def recv(self, timeout: Optional[float]=None) -> Union[ClientEvent, None]

Source

Receive a ClientEvent from the server.

:param timeout: Optional timeout in seconds :return: ClientEvent or None if connection closed :raises ConnectionError: If not connected

Public imports

These symbols are available from this module. Their definitions are documented in the linked modules.