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.
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
| Version | Description |
|---|---|
| 7.0.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.