diff --git a/src/broadcasting/src/BroadcastPoolProxy.php b/src/broadcasting/src/BroadcastPoolProxy.php index c8e71cbd2..a15cb0c22 100644 --- a/src/broadcasting/src/BroadcastPoolProxy.php +++ b/src/broadcasting/src/BroadcastPoolProxy.php @@ -6,10 +6,21 @@ use Hyperf\HttpServer\Contract\RequestInterface; use Hypervel\Broadcasting\Contracts\Broadcaster; +use Hypervel\Broadcasting\Contracts\HasBroadcastChannel; use Hypervel\ObjectPool\PoolProxy; class BroadcastPoolProxy extends PoolProxy implements Broadcaster { + /** + * Register a channel authenticator. + */ + public function channel(HasBroadcastChannel|string $channel, callable|string $callback, array $options = []): static + { + $this->__call(__FUNCTION__, func_get_args()); + + return $this; + } + public function auth(RequestInterface $request): mixed { return $this->__call(__FUNCTION__, func_get_args()); diff --git a/src/broadcasting/src/Contracts/Broadcaster.php b/src/broadcasting/src/Contracts/Broadcaster.php index d7c09468c..272c81755 100644 --- a/src/broadcasting/src/Contracts/Broadcaster.php +++ b/src/broadcasting/src/Contracts/Broadcaster.php @@ -8,6 +8,11 @@ interface Broadcaster { + /** + * Register a channel authenticator. + */ + public function channel(HasBroadcastChannel|string $channel, callable|string $callback, array $options = []): static; + /** * Authenticate the incoming request for a given channel. */ diff --git a/src/support/src/Facades/Broadcast.php b/src/support/src/Facades/Broadcast.php index ff279e48c..bd84b6f22 100644 --- a/src/support/src/Facades/Broadcast.php +++ b/src/support/src/Facades/Broadcast.php @@ -33,6 +33,7 @@ * @method static \Hypervel\Broadcasting\BroadcastManager removePoolable(string $driver) * @method static array getPoolables() * @method static \Hypervel\Broadcasting\BroadcastManager setPoolables(array $poolables) + * @method static \Hypervel\Broadcasting\Contracts\Broadcaster channel(\Hypervel\Broadcasting\Contracts\HasBroadcastChannel|string $channel, callable|string $callback, array $options = []) * @method static mixed auth(\Hyperf\HttpServer\Contract\RequestInterface $request) * @method static mixed validAuthenticationResponse(\Hyperf\HttpServer\Contract\RequestInterface $request, mixed $result) * @method static void broadcast(array $channels, string $event, array $payload = [])