first commit

This commit is contained in:
exercict
2026-07-14 08:10:11 +04:00
commit fdfb0dd62e
60 changed files with 9930 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace App\Services\WebSocket;
class EventPublisher
{
private string $queueFile;
public function __construct()
{
$this->queueFile = __DIR__ . '/../../../storage/ws/events.log';
}
public function publish(array $payload): void
{
$dir = dirname($this->queueFile);
if (!is_dir($dir)) {
mkdir($dir, 0775, true);
}
$line = json_encode($payload, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
if ($line === false) {
return;
}
file_put_contents($this->queueFile, $line . PHP_EOL, FILE_APPEND | LOCK_EX);
}
}