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)

get_client_info

python
def get_client_info() -> dict

Source

Gather Python client system information.

Returns a dictionary with system info for the INIT event:

Common fields (shared with browser client):

  • client: Always "python" to distinguish from browser clients
  • clientVersion: The vuer library version
  • timezone: IANA timezone name (e.g., "America/Los_Angeles")
  • timezoneOffset: Timezone offset in minutes from UTC

Python-specific fields:

  • pythonVersion: Python version string (e.g., "3.11.13")
  • platform: Operating system name (e.g., "Darwin", "Linux", "Windows")
  • platformVersion: OS kernel version string
  • machine: Machine architecture (e.g., "x86_64", "arm64")

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). max_size: Maximum WebSocket message size (env: WEBSOCKET_MAX_SIZE, default 256MB). ssl_verify: Whether to verify SSL certificates (env: VUER_SSL_VERIFY, default True).

python
uri: str = EnvVar @ 'VUER_CLIENT_URI' | 'ws://localhost:8012'
python
websocket_max_size: int = EnvVar @ 'WEBSOCKET_MAX_SIZE' | 2 ** 28
python
ssl_verify: bool = EnvVar @ 'VUER_SSL_VERIFY' | True

VuerClient.init

python
def __init__(self, uri: str=None, max_size: int=None, ssl_verify: bool=None, **kwargs)

Source

Initialize the Vuer client.

:param uri: WebSocket URI to connect to (e.g., "ws://localhost:8012") :param max_size: Maximum websocket message size in bytes (default 256MB) :param ssl_verify: Whether to verify SSL certificates (default True, env: VUER_SSL_VERIFY). Set to False for self-signed certs (e.g., ngrok tunnels). :param kwargs: Additional keyword arguments passed to websockets.connect() (e.g., ssl=ssl_context for custom SSL/TLS configuration)

VuerClient.connect

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

Source

Connect to the Vuer server and send INIT event with client info.

: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.