<?php /** @noinspection DuplicatedCode */
/** @noinspection DuplicatedCode */
/** @noinspection PhpUnhandledExceptionInspection */
/** @noinspection PhpUnusedParameterInspection */
use Eftec\MultiOne\MultiOne;
include __DIR__ . '/../vendor/autoload.php';
MultiOne::Factory(
1000, // every miliseconds
basename(__FILE__), // the url to call
)->setMethods(
static function($numWorkers, $payload): array { // the initial call
$_SESSION['USERNAME'] = 'admin';
return ["Start",
];
},
static function($idWorker, $payload): array { // the worker call
// it reads the data and reduces to 1.
$username=$_SESSION['USERNAME']??null;
if($username===null) {
throw new RuntimeException('no user is not set');
}
return MultiOne::msgRun("$username:{$payload['line']}","@$username> ");
}
)
->setCli('> ','100%','600px') // we use a cli
->runAuto();
|