WP_HTTP_Polling_Sync_Server::get_updates( string $room, int $client_id, int $cursor, bool $is_compactor ): array{

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.

Gets sync updates for a specific client from a room after a given cursor.

Description

Delegates cursor-based retrieval to the storage layer, then applies client-specific filtering and compaction logic.

Parameters

$roomstringrequired
Room identifier.
$client_idintrequired
Client identifier.
$cursorintrequired
Return updates after this cursor.
$is_compactorboolrequired
True if this client is nominated to perform compaction.

Return

array{ end_cursor: int, should_compact: bool, room: string, total_updates: int, updates: array<int, array{data: string, type: string}>, } Response data for this room.

Source

private function get_updates( string $room, int $client_id, int $cursor, bool $is_compactor ): array {
	$updates_after_cursor = $this->storage->get_updates_after_cursor( $room, $cursor );
	$total_updates        = $this->storage->get_update_count( $room );

	// Filter out this client's updates, except compaction updates.
	$typed_updates = array();
	foreach ( $updates_after_cursor as $update ) {
		if ( $client_id === $update['client_id'] && self::UPDATE_TYPE_COMPACTION !== $update['type'] ) {
			continue;
		}

		$typed_updates[] = array(
			'data' => $update['data'],
			'type' => $update['type'],
		);
	}

	$should_compact = $is_compactor && $total_updates > self::COMPACTION_THRESHOLD;

	return array(
		'end_cursor'     => $this->storage->get_cursor( $room ),
		'room'           => $room,
		'should_compact' => $should_compact,
		'total_updates'  => $total_updates,
		'updates'        => $typed_updates,
	);
}

Changelog

VersionDescription
7.0.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.