A progress response to controller

This commit is contained in:
Blax Software 2025-01-20 16:46:13 +01:00
parent 095894da1e
commit 7907258908
1 changed files with 29 additions and 0 deletions

View File

@ -166,6 +166,35 @@ class Controller
} }
} }
final public function progress(
mixed $payload = null,
?string $event = null,
?string $channel = null
) : bool {
$p = [
'event' => ($event ?? $this->event) . ':progress',
'data' => $payload,
'channel' => $channel ?? $this->channel->getName(),
];
// if payload only contains key "data"
if (
count($p) === 1
&& isset($payload['data'])
) {
$p['data'] = $payload['data'];
}
if (get_class($this->connection) === MockConnection::class) {
$connection = clone $this->connection;
$connection->send(json_encode($p));
} else {
$this->connection->send(json_encode($p));
}
return true;
}
final public function success( final public function success(
mixed $payload = null, mixed $payload = null,
?string $event = null, ?string $event = null,