Websocket cluster addon base redis subscribe.
-
Requirements
- PHP >= 8.1
- Swoole >= 5.0.0
- hyperf/websocket-server >= 3.1.0
-
Composer install
composer require friendsofhyperf/websocket-cluster-addon:^5.0
- Publish
php bin/hyperf.php vendor:publish friendsofhyperf/websocket-cluster-addon
- Send message
use FriendsOfHyperf\WebsocketClusterAddon\Emitter;
$emitter = $container->get(Emitter::class);
$emitter->emit($contactId, $message);
- Broadcast message
use FriendsOfHyperf\WebsocketClusterAddon\Emitter;
$emitter = $container->get(Emitter::class);
$emitter->broadcast($message);
-
Node
- Memory
default
- Redis
- Swoole Table
- Memory
-
Client
- Redis
default
- Swoole Table
- Redis