friendsofhyperf/websocket-cluster-addon

Websocket cluster addon base redis subscribe.

v5.0.0-beta.2 2024-04-28 06:10 UTC

README

Latest Test Latest Stable Version Total Downloads GitHub license

Websocket cluster addon base redis subscribe.

Installation

  • Requirements

    • PHP >= 8.0
    • Swoole >= 4.5.10
    • hyperf/websocket-server >= 3.0
  • Composer install

composer require friendsofhyperf/websocket-cluster-addon:^4.0
  • Publish
php bin/hyperf.php vendor:publish friendsofhyperf/websocket-cluster-addon

Usage

  • 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);

Examples

Drivers

  • Node

    • Memory default
    • Redis
    • Swoole Table
  • Client

    • Redis default
    • Swoole Table