friendsofhyperf/websocket-cluster-addon

Websocket cluster addon base redis subscribe.

v5.0.1 2024-11-21 08:10 UTC

README

Latest Test Latest Stable Version Total Downloads License GitHub license

Websocket cluster addon base redis subscribe.

Installation

  • 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

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