Skip to content

unienv_interface.remote.server

Explicit resource registry and serialized execution domains.

HostedResource module-attribute

HostedResource = Union[Env, World, WorldNode]

ResourceFactory module-attribute

ResourceFactory = Callable[[], HostedResource]

DomainKey module-attribute

DomainKey = Union[int, str, Tuple[str, int]]

SnapshotCaptures module-attribute

SnapshotCaptures = Dict[Tuple[str, str], Tuple[Dict[str, Any], Optional[Exception]]]

SERVER_VERSION module-attribute

SERVER_VERSION = version('unienv')

RemoteServer

RemoteServer(*, max_message_size: int = DEFAULT_MAX_MESSAGE_SIZE, idle_timeout: Optional[float] = 60.0)

Host objects or lazy root factories. Register resources before connecting.

Registration doesn't call lifecycle methods. All discovery, lifecycle, snapshots, and cleanup execute on the resource's dedicated world worker. Only factory registrations are evicted after idle_timeout seconds.

codec instance-attribute

codec = Codec(max_message_size)

idle_timeout instance-attribute

idle_timeout = idle_timeout

register

register(resource_id: str, obj_or_factory: Union[HostedResource, ResourceFactory]) -> str

Register an Env, World, WorldNode, or zero-arg root factory.

WorldEnv exports its world and complete node tree automatically. Re-registering the same object returns its existing ID, without aliases. World/node relationships and child names must stay fixed after registration. Factories run on the world worker on first access (including discovery). Their topology must remain identical across idle eviction and revival. A root WorldNode with world=None owns a separate domain, including its detached children. Each node must declare a backend; device defaults to None for RPC coercion. Devices secretly shared by detached nodes have no ownership protection, so their construction must be trusted.

attach

attach(transport: MessageTransport) -> _Session

Accept a connected MessageTransport, starting a session in background.

connect

connect(**client_options: object) -> RemoteClient

Create an in-memory RemoteClient using the full wire protocol.

listen

listen(host: str = '127.0.0.1', port: int = 0) -> str

Start the optional WebSocket listener; return its ws:// endpoint.

close

close() -> None