phpsoftbox / broadcaster
Broadcaster component for the PhpSoftBox framework (Pushr)
dev-master
2026-03-05 11:40 UTC
Requires
- php: ^8.4
- psr/http-message: ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.93
- phpsoftbox/cli-app: dev-master
- phpsoftbox/cs-fixer: ^1.1.0
- phpunit/phpunit: ^11.2
This package is auto-updated.
Last update: 2026-03-05 11:40:08 UTC
README
About
phpsoftbox/broadcaster — компонент для запуска WebSocket сервера и обмена сообщениями между сервисами. Драйвер Pushr реализует собственный протокол с авторизацией по app_id и signature.
Ключевые свойства:
- сервер
PushrServer(WebSocket) - клиент
PushrClientдля публикации/подписки - подписи
PushrSignature - подписи каналов
PushrChannelAuth - реестр каналов
ChannelRegistry - поддержка каналов (rooms), включая приватные
Quick Start
Запуск сервера:
use PhpSoftBox\Broadcaster\Pushr\PushrAppRegistry; use PhpSoftBox\Broadcaster\Pushr\PushrServer; $registry = new PushrAppRegistry([ 'app-1' => 'secret-1', ]); $server = new PushrServer($registry, host: '0.0.0.0', port: 8080); $server->run();
Подключение клиентом:
use PhpSoftBox\Broadcaster\Pushr\PushrClient; $client = new PushrClient('127.0.0.1', 8080, 'app-1', 'secret-1'); $client->connect(); $client->subscribe('news'); $client->publish('news', 'message', ['text' => 'hello']);
Публикация из PHP-кода без постоянного подключения:
use PhpSoftBox\Broadcaster\Pushr\PushrPublisher; $publisher = new PushrPublisher('app-1', 'secret-1', '127.0.0.1', 8080); $publisher->publish('news', 'message', ['text' => 'hello']);