# 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)

*** ** * ** ***


```
public final class A2uiCoreMessageProcessor implements 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/androidx/a2ui/engine/processor/A2uiCoreSurfaceActor`, and exposes the outbound network events back to the host framework.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/a2ui/engine/processor/A2uiCoreMessageProcessor#A2uiCoreMessageProcessor(kotlin.collections.List,kotlin.Function0,kotlin.Function0,kotlin.collections.List)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/engine/catalog/A2uiCoreCatalog> catalogs, @https://developer.android.com/reference/androidx/annotation/NonNull Function0<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/engine/platform/A2uiCoreDataModel> dataModelFactory, @https://developer.android.com/reference/androidx/annotation/NonNull Function0<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/engine/platform/A2uiCoreComponentRegistry> componentRegistryFactory, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/model/processor/A2uiActionInterceptor> actionInterceptors )` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/a2ui/engine/processor/A2uiCoreMessageProcessor#collectMessages()()` Continuously consumes the inbound message queue and routes messages to surface actors. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-state-flow/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/model/processor/A2uiSurfaceModel>>` | `https://developer.android.com/reference/androidx/a2ui/engine/processor/A2uiCoreMessageProcessor#getActiveSurfaces()()` A flow of the list of active surface ids currently managed by the processor. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/model/protocol/A2uiClientCapabilities` | `https://developer.android.com/reference/androidx/a2ui/engine/processor/A2uiCoreMessageProcessor#getClientCapabilities()()` The client capabilities supported by this processor instance, derived from the registered catalogs. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/model/protocol/A2uiClientToServerMessage>` | `https://developer.android.com/reference/androidx/a2ui/engine/processor/A2uiCoreMessageProcessor#getOutboundEvents()()` A flow of user actions and error payloads to be transmitted to the server. |
| `void` | `https://developer.android.com/reference/androidx/a2ui/engine/processor/A2uiCoreMessageProcessor#processError(androidx.a2ui.model.protocol.A2uiClientErrorMessage)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/model/protocol/A2uiClientErrorMessage error)` Enqueues a client error message to be transmitted back to the server via `https://developer.android.com/reference/androidx/a2ui/model/processor/A2uiMessageProcessor#outboundEvents()`. |
| `void` | `https://developer.android.com/reference/androidx/a2ui/engine/processor/A2uiCoreMessageProcessor#processMessage(androidx.a2ui.model.protocol.A2uiServerToClientMessage)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/model/protocol/A2uiServerToClientMessage message)` Enqueues a parsed protocol message to be processed by the core engine. |

## Public constructors

### A2uiCoreMessageProcessor

```
public A2uiCoreMessageProcessor(
    @NonNull List<@NonNull A2uiCoreCatalog> catalogs,
    @NonNull Function0<@NonNull A2uiCoreDataModel> dataModelFactory,
    @NonNull Function0<@NonNull A2uiCoreComponentRegistry> componentRegistryFactory,
    @NonNull List<@NonNull A2uiActionInterceptor> actionInterceptors
)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/engine/catalog/A2uiCoreCatalog> catalogs` | The list of available component catalogs. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function0<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/engine/platform/A2uiCoreDataModel> dataModelFactory` | Factory for creating new instances of `https://developer.android.com/reference/androidx/a2ui/engine/platform/A2uiCoreDataModel`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function0<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/engine/platform/A2uiCoreComponentRegistry> componentRegistryFactory` | Factory for creating new instances of `https://developer.android.com/reference/androidx/a2ui/engine/platform/A2uiCoreComponentRegistry`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/model/processor/A2uiActionInterceptor> actionInterceptors` | A list of `https://developer.android.com/reference/androidx/a2ui/model/processor/A2uiActionInterceptor` instances to intercept UI actions. |

## Public methods

### collectMessages

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

```
public void collectMessages()
```

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.

### getActiveSurfaces

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

```
public @NonNull StateFlow<@NonNull List<@NonNull A2uiSurfaceModel>> getActiveSurfaces()
```

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

### getClientCapabilities

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

```
public final @NonNull A2uiClientCapabilities getClientCapabilities()
```

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.

### getOutboundEvents

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

```
public @NonNull Flow<@NonNull A2uiClientToServerMessage> getOutboundEvents()
```

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

### processError

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

```
public void processError(@NonNull A2uiClientErrorMessage error)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/model/protocol/A2uiClientErrorMessage error` | 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)

```
public void processMessage(@NonNull A2uiServerToClientMessage message)
```

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

This method is safe to call from any thread.