> ## Documentation Index
> Fetch the complete documentation index at: https://docs.generalrobotics.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# ZenohClient

> Abstract base class for Zenoh pub/sub clients

```python theme={null}
from grid_sim_client.isaac import ZenohClient
```

Abstract base class for Zenoh pub/sub clients.

## Constructor

```python Signature theme={null}
ZenohClient(
    *,
    client_dict: Optional[dict] = None,
    agent_dict: Optional[dict] = None,
    shared_session: Any = None,
)
```

## Methods

### `getLatestMessage()`

```python Signature theme={null}
getLatestMessage() -> Any
```

Return the most recent message from the subscription queue.

Blocks for up to one second waiting for a message.

**Returns:**

The raw payload bytes of the latest message, or `None` if no
message was received within the timeout.

### `msg_cb()`

```python Signature theme={null}
msg_cb(sample: Any) -> None
```

Handle an incoming Zenoh sample by storing its payload in the queue.

<ParamField body="sample" required>
  The Zenoh sample received from the subscription.
</ParamField>

### `process_latest_msg()`

```python Signature theme={null}
process_latest_msg() -> None
```

Process the latest message from the queue. Override in subclasses.

### `publish()`

```python Signature theme={null}
publish(data: bytes) -> None
```

Publish data to the topic.

<ParamField body="data" required>
  Raw bytes to publish on the configured topic.
</ParamField>

### `run()`

```python Signature theme={null}
run() -> None
```

Start the client by declaring a subscriber or publisher on the session.

### `stop()`

```python Signature theme={null}
stop() -> None
```

Undeclare the subscriber and close the owned Zenoh session if any.


## Related topics

- [connect](/python-api/grid-nexus-client/connect.md)
- [GRID Cortex Client](/models/cortex.md)
- [grid-cortex-client](/python-api/grid-cortex-client/overview.md)
- [CortexClient](/python-api/grid-cortex-client/cortexclient.md)
- [AsyncCortexClient](/python-api/grid-cortex-client/asynccortexclient.md)
