Title: WP_HTTP_Polling_Sync_Server::process_awareness_update
Published: May 20, 2026

---

# WP_HTTP_Polling_Sync_Server::process_awareness_update( string $room, int $client_id,  $awareness_update ): array<int,

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_http_polling_sync_server/process_awareness_update/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_http_polling_sync_server/process_awareness_update/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_http_polling_sync_server/process_awareness_update/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_http_polling_sync_server/process_awareness_update/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_http_polling_sync_server/process_awareness_update/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_http_polling_sync_server/process_awareness_update/?output_format=md#wp--skip-link--target)

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Processes and stores an awareness update from a client.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_http_polling_sync_server/process_awareness_update/?output_format=md#parameters)󠁿

 `$room`stringrequired

Room identifier.

`$client_id`intrequired

Client identifier.

mixed>|null $awareness_update Awareness state sent by the client.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_http_polling_sync_server/process_awareness_update/?output_format=md#return)󠁿

 array<int, array<string, mixed>> Map of client ID to awareness state.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_http_polling_sync_server/process_awareness_update/?output_format=md#source)󠁿

    ```php
    private function process_awareness_update( string $room, int $client_id, ?array $awareness_update ): array {
    	$existing_awareness = $this->storage->get_awareness_state( $room );
    	$updated_awareness  = array();
    	$current_time       = time();

    	foreach ( $existing_awareness as $entry ) {
    		// Remove this client's entry (it will be updated below).
    		if ( $client_id === $entry['client_id'] ) {
    			continue;
    		}

    		// Remove entries that have expired.
    		if ( $current_time - $entry['updated_at'] >= self::AWARENESS_TIMEOUT ) {
    			continue;
    		}

    		$updated_awareness[] = $entry;
    	}

    	// Add this client's awareness state.
    	if ( null !== $awareness_update ) {
    		$updated_awareness[] = array(
    			'client_id'  => $client_id,
    			'state'      => $awareness_update,
    			'updated_at' => $current_time,
    			'wp_user_id' => get_current_user_id(),
    		);
    	}

    	// This action can fail, but it shouldn't fail the entire request.
    	$this->storage->set_awareness_state( $room, $updated_awareness );

    	// Convert to client_id => state map for response.
    	$response = array();
    	foreach ( $updated_awareness as $entry ) {
    		$response[ $entry['client_id'] ] = $entry['state'];
    	}

    	return $response;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/collaboration/class-wp-http-polling-sync-server.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/collaboration/class-wp-http-polling-sync-server.php#L413)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/collaboration/class-wp-http-polling-sync-server.php#L413-L452)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_http_polling_sync_server/process_awareness_update/?output_format=md#related)󠁿

| Uses | Description | 
| [get_current_user_id()](https://developer.wordpress.org/reference/functions/get_current_user_id/)`wp-includes/user.php` |

Gets the current user’s ID.

  |

| Used by | Description | 
| [WP_HTTP_Polling_Sync_Server::handle_request()](https://developer.wordpress.org/reference/classes/wp_http_polling_sync_server/handle_request/)`wp-includes/collaboration/class-wp-http-polling-sync-server.php` |

Handles request: stores sync updates and awareness data, and returns updates the client is missing.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_http_polling_sync_server/process_awareness_update/?output_format=md#changelog)󠁿

| Version | Description | 
| [7.0.0](https://developer.wordpress.org/reference/since/7.0.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_http_polling_sync_server%2Fprocess_awareness_update%2F)
before being able to contribute a note or feedback.