WP_HTTP_Polling_Sync_Server::add_update
Adds an update to a room's update list via storage.
Method of the class: WP_HTTP_Polling_Sync_Server{}
No Hooks.
Returns
true|WP_Error. True on success, WP_Error on storage failure.
Usage
// private - for code of main (parent) class only $result = $this->add_update( $room, $client_id, $type, $data );
- $room(string) (required)
- Room identifier.
- $client_id(int) (required)
- Client identifier.
- $type(string) (required)
- Update type (sync_step1, sync_step2, update, compaction).
- $data(string) (required)
- Base64-encoded update data.
Changelog
| Since 7.0.0 | Introduced. |
WP_HTTP_Polling_Sync_Server::add_update() WP HTTP Polling Sync Server::add update code WP 7.0
private function add_update( string $room, int $client_id, string $type, string $data ) {
$update = array(
'client_id' => $client_id,
'data' => $data,
'type' => $type,
);
if ( ! $this->storage->add_update( $room, $update ) ) {
return new WP_Error(
'rest_sync_storage_error',
__( 'Failed to store sync update.' ),
array( 'status' => 500 )
);
}
return true;
}