Skip to content

friendsofhyperf/websocket-cluster-addon

Repository files navigation

websocket-cluster-addon

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