Creo que los tiempos son Staggered por naturaleza, ya que la siguiente marca está determinada por el tiempo del navegador time()
dentro del método scheduleNextTick()
en el /wp-includes/js/heartbeat.js
de archivo:
var delta = time() - settings.lastTick,
interval = settings.mainInterval;
donde se usa para programar el siguiente tick con la función setTimeout
:
if ( delta < interval ) {
settings.beatTimer = window.setTimeout(
function() {
connect();
},
interval - delta
);
} else {
connect();
}
El tiempo del navegador se define como:
function time() {
return (new Date()).getTime();
}
El método connect()
contiene la llamada ajax y usa always()
.always( function() {
settings.connecting = false;
scheduleNextTick();
})
para programar el siguiente tick.
Los intervalos de marcación disponibles son 5s, 15s, 30s y 60s.
Para un gran número de usuarios muy activos, con un breve intervalo de tics, puede parecer que los latidos ocurren simultáneamente.
Siempre es bueno tener algunos datos, por lo que podría registrar los ticks de los usuarios registrados, con el heartbeat_tick
hook:
add_action( 'heartbeat_tick',
function( $response, $screen_id )
{
$file = WP_CONTENT_DIR . '/ticks.log'; // Edit this filepath to your needs.
if( file_exists( $file ) && is_writeable( $file ) )
{
file_put_contents(
$file,
sprintf( "%s - Tick from user_id : %d - from screen_id : %s" . PHP_EOL,
date( 'c' ),
get_current_user_id(),
$screen_id
),
FILE_APPEND | LOCK_EX
);
}
}
, 11, 2 );
Aquí hay un ejemplo del archivo ticks.log
:
2014-09-01T12:41:04+00:00 - Tick from user_id : 1 - from screen_id : edit-post
2014-09-01T12:41:19+00:00 - Tick from user_id : 1 - from screen_id : edit-post
2014-09-01T12:41:34+00:00 - Tick from user_id : 1 - from screen_id : edit-post
2014-09-01T12:41:56+00:00 - Tick from user_id : 1 - from screen_id : post
2014-09-01T12:42:11+00:00 - Tick from user_id : 1 - from screen_id : post
2014-09-01T12:42:20+00:00 - Tick from user_id : 3 - from screen_id : upload
2014-09-01T12:42:38+00:00 - Tick from user_id : 1 - from screen_id : post
2014-09-01T12:43:05+00:00 - Tick from user_id : 1 - from screen_id : post
2014-09-01T12:43:08+00:00 - Tick from user_id : 3 - from screen_id : attachment
2014-09-01T12:43:20+00:00 - Tick from user_id : 1 - from screen_id : post
2014-09-01T12:43:36+00:00 - Tick from user_id : 1 - from screen_id : post
2014-09-01T12:44:17+00:00 - Tick from user_id : 3 - from screen_id : profile