friendsofhyperf/websocket-cluster-addon

Websocket cluster addon base redis subscribe.

3.0.8 2021-04-14 07:18 UTC

README

Latest Test Latest Stable Version Total Downloads GitHub license

Websocket cluster addon base redis subscribe.

Installation

  • Requirements

    • PHP >= 7.2
    • Swoole >= 4.5.10
    • hyperf/websocket-server >= 2.0
  • Composer install

composer require friendsofhyperf/websocket-cluster-addon
  • 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