---
title: "vuer.rtc.operations.dispatcher"
section: "Python API"
order: 16
description: "Python API reference for vuer.rtc.operations.dispatcher"
---

# vuer.rtc.operations.dispatcher

Dispatcher for applying CRDT messages and operations to scene graphs.

This module provides functions that match the TypeScript API:
- applyMessage(graph, msg) -&gt; new_graph (immutable)
- applyMessages(graph, messages) -&gt; new_graph (immutable)
- applyOperation(graph, op, meta) -&gt; None (mutable)
- applyMessageMut(graph, msg) -&gt; None (mutable)
- applyMessagesMut(graph, messages) -&gt; None (mutable)

## OperationMeta

```python
class OperationMeta
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/docs/v0.1.6/src/vuer/rtc/operations/dispatcher.py#L26)

Metadata passed to apply functions.

Attributes:
    lamport_time: Lamport timestamp for LWW operations
    session_id: Session that created the operation
    timestamp: Wall-clock timestamp

## OperationMeta.__init__

```python
def __init__(self, lamport_time: int, session_id: str='', timestamp: Optional[float]=None)
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/docs/v0.1.6/src/vuer/rtc/operations/dispatcher.py#L36)

## apply_operation

```python
def apply_operation(graph: SceneGraph, op: Operation, meta: OperationMeta) -> None
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/docs/v0.1.6/src/vuer/rtc/operations/dispatcher.py#L47)

Apply a single operation to the graph (mutable, modifies in place).

Args:
    graph: The scene graph to modify
    op: The operation to apply
    meta: Operation metadata (lamport time, session ID, etc.)

Raises:
    ValueError: If the operation type is not supported or node not found

## apply_message_mut

```python
def apply_message_mut(graph: SceneGraph, msg: CRDTMessage) -> None
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/docs/v0.1.6/src/vuer/rtc/operations/dispatcher.py#L153)

Apply a CRDT message to the graph (mutable, modifies in place).

Args:
    graph: The scene graph to modify
    msg: The message containing operations to apply

## apply_messages_mut

```python
def apply_messages_mut(graph: SceneGraph, messages: List[CRDTMessage]) -> None
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/docs/v0.1.6/src/vuer/rtc/operations/dispatcher.py#L171)

Apply multiple CRDT messages to the graph (mutable, modifies in place).

Messages are applied in order. For correct behavior, ensure messages
are sorted by lamport time.

Args:
    graph: The scene graph to modify
    messages: List of messages to apply

## apply_message

```python
def apply_message(graph: SceneGraph, msg: CRDTMessage) -> SceneGraph
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/docs/v0.1.6/src/vuer/rtc/operations/dispatcher.py#L186)

Apply a CRDT message to the graph (immutable, returns new graph).

Args:
    graph: The source scene graph (not modified)
    msg: The message containing operations to apply

Returns:
    A new SceneGraph with the operations applied

## apply_messages

```python
def apply_messages(graph: SceneGraph, messages: List[CRDTMessage]) -> SceneGraph
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/docs/v0.1.6/src/vuer/rtc/operations/dispatcher.py#L202)

Apply multiple CRDT messages to the graph (immutable, returns new graph).

Messages are applied in order. For correct behavior, ensure messages
are sorted by lamport time.

Args:
    graph: The source scene graph (not modified)
    messages: List of messages to apply

Returns:
    A new SceneGraph with all operations applied

## rebuild_graph

```python
def rebuild_graph(snapshot_graph: SceneGraph, journal_entries: List['JournalEntry'], pending_ops: Optional[List[Operation]]=None, lamport_time: int=0, session_id: str='') -> SceneGraph
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/docs/v0.1.6/src/vuer/rtc/operations/dispatcher.py#L221)

Rebuild the graph from a snapshot and journal entries.

This is used after undo/redo or when restoring from a checkpoint.

Args:
    snapshot_graph: The starting graph state
    journal_entries: Journal entries to replay (filtered for non-deleted)
    pending_ops: Optional uncommitted operations to apply
    lamport_time: Current lamport time for pending ops
    session_id: Session ID for pending ops

Returns:
    Rebuilt scene graph

## Public imports

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

- [`CRDTMessage`](/python-api/rtc/types#crdtmessage) — `vuer.rtc.types.CRDTMessage`
- [`Operation`](/python-api/rtc/types#operation) — `vuer.rtc.types.Operation`
- [`SceneGraph`](/python-api/rtc/types#scenegraph) — `vuer.rtc.types.SceneGraph`
- [`SceneNode`](/python-api/rtc/types#scenenode) — `vuer.rtc.types.SceneNode`
- [`OType`](/python-api/rtc/types#otype) — `vuer.rtc.types.OType`
- [`merge_clocks`](/python-api/rtc/types#merge_clocks) — `vuer.rtc.types.merge_clocks`
