# A2uiCoreMessageProcessor

Artifact: [androidx.a2ui:a2ui-engine](https://developer.android.com/jetpack/androidx/releases/a2ui) [View Source](https://cs.android.com/search?q=file:androidx/a2ui/engine/processor/A2uiCoreMessageProcessor.kt+class:androidx.a2ui.engine.processor.A2uiCoreMessageProcessor) Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

*** ** * ** ***


```
class A2uiCoreMessageProcessor : A2uiMessageProcessor
```

<br />

*** ** * ** ***

The central orchestration engine for the A2UI core data layer.

It receives parsed protocol messages from the host application, routes them to the appropriate sequential `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/processor/A2uiCoreSurfaceActor`, and exposes the outbound network events back to the host framework.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/processor/A2uiCoreMessageProcessor#A2uiCoreMessageProcessor(kotlin.collections.List,kotlin.Function0,kotlin.Function0,kotlin.collections.List)( catalogs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/a2ui/engine/catalog/A2uiCoreCatalog>, dataModelFactory: () -> https://developer.android.com/reference/kotlin/androidx/a2ui/engine/platform/A2uiCoreDataModel, componentRegistryFactory: () -> https://developer.android.com/reference/kotlin/androidx/a2ui/engine/platform/A2uiCoreComponentRegistry, actionInterceptors: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/a2ui/model/processor/A2uiActionInterceptor> )` |

| ### Public functions |
|---|---|
| `open suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/processor/A2uiCoreMessageProcessor#collectMessages()()` Continuously consumes the inbound message queue and routes messages to surface actors. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/processor/A2uiCoreMessageProcessor#processError(androidx.a2ui.model.protocol.A2uiClientErrorMessage)(error: https://developer.android.com/reference/kotlin/androidx/a2ui/model/protocol/A2uiClientErrorMessage)` Enqueues a client error message to be transmitted back to the server via `https://developer.android.com/reference/kotlin/androidx/a2ui/model/processor/A2uiMessageProcessor#outboundEvents()`. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/processor/A2uiCoreMessageProcessor#processMessage(androidx.a2ui.model.protocol.A2uiServerToClientMessage)(message: https://developer.android.com/reference/kotlin/androidx/a2ui/model/protocol/A2uiServerToClientMessage)` Enqueues a parsed protocol message to be processed by the core engine. |

| ### Public properties |
|---|---|
| `open https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-state-flow/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/a2ui/model/processor/A2uiSurfaceModel>>` | `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/processor/A2uiCoreMessageProcessor#activeSurfaces()` A flow of the list of active surface ids currently managed by the processor. |
| `https://developer.android.com/reference/kotlin/androidx/a2ui/model/protocol/A2uiClientCapabilities` | `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/processor/A2uiCoreMessageProcessor#clientCapabilities()` The client capabilities supported by this processor instance, derived from the registered catalogs. |
| `open https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<https://developer.android.com/reference/kotlin/androidx/a2ui/model/protocol/A2uiClientToServerMessage>` | `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/processor/A2uiCoreMessageProcessor#outboundEvents()` A flow of user actions and error payloads to be transmitted to the server. |

## Public constructors

### A2uiCoreMessageProcessor

```
A2uiCoreMessageProcessor(
    catalogs: List<A2uiCoreCatalog>,
    dataModelFactory: () -> A2uiCoreDataModel,
    componentRegistryFactory: () -> A2uiCoreComponentRegistry,
    actionInterceptors: List<A2uiActionInterceptor> = emptyList()
)
```

| Parameters |
|---|---|
| `catalogs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/a2ui/engine/catalog/A2uiCoreCatalog>` | The list of available component catalogs. |
| `dataModelFactory: () -> https://developer.android.com/reference/kotlin/androidx/a2ui/engine/platform/A2uiCoreDataModel` | Factory for creating new instances of `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/platform/A2uiCoreDataModel`. |
| `componentRegistryFactory: () -> https://developer.android.com/reference/kotlin/androidx/a2ui/engine/platform/A2uiCoreComponentRegistry` | Factory for creating new instances of `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/platform/A2uiCoreComponentRegistry`. |
| `actionInterceptors: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/a2ui/model/processor/A2uiActionInterceptor> = emptyList()` | A list of `https://developer.android.com/reference/kotlin/androidx/a2ui/model/processor/A2uiActionInterceptor` instances to intercept UI actions. |

## Public functions

### collectMessages

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

```
open suspend fun collectMessages(): Unit
```

Continuously consumes the inbound message queue and routes messages to surface actors.

This function must be launched within the host application's lifecycle scope (e.g., a ViewModel scope). When the scope is cancelled, this loop and all child surface actors are naturally terminated.

### processError

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

```
open fun processError(error: A2uiClientErrorMessage): Unit
```

Enqueues a client error message to be transmitted back to the server via `https://developer.android.com/reference/kotlin/androidx/a2ui/model/processor/A2uiMessageProcessor#outboundEvents()`.

| Parameters |
|---|---|
| `error: https://developer.android.com/reference/kotlin/androidx/a2ui/model/protocol/A2uiClientErrorMessage` | The client error message to transmit. |

### processMessage

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

```
open fun processMessage(message: A2uiServerToClientMessage): Unit
```

Enqueues a parsed protocol message to be processed by the core engine.

This method is safe to call from any thread.

## Public properties

### activeSurfaces

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

```
open val activeSurfaces: StateFlow<List<A2uiSurfaceModel>>
```

A flow of the list of active surface ids currently managed by the processor.

### clientCapabilities

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

```
val clientCapabilities: A2uiClientCapabilities
```

The client capabilities supported by this processor instance, derived from the registered catalogs. Host applications can query this directly during system initialization to send to the agent.

### outboundEvents

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

```
open val outboundEvents: Flow<A2uiClientToServerMessage>
```

A flow of user actions and error payloads to be transmitted to the server.