Ilya Degtyarenko
Ilya Degtyarenko

Reputation: 1589

How can I send data to multiple channels at once? (laravel, broadcasting)

I have one event for broadcasting, there is channel for subscription on client side:

/**
* Get the channels the event should broadcast on.
*
* @return PrivateChannel
*/
public function broadcastOn()
{
    return new PrivateChannel("user.{$this->userId}");
}

How can I send data to multiple channels at once (on user.1, user.2, user.3 ...)?

Refinement, to specific users, not to everyone who has subscribed to the room.

Upvotes: 1

Views: 1339

Answers (1)

Ilya Degtyarenko
Ilya Degtyarenko

Reputation: 1589

I have found solution.

/**
* Get the channels the event should broadcast on.
*
* @return PrivateChannel|array
*/
public function broadcastOn()
{
    return [
        new PrivateChannel("user.{$this->userId}"),
        new PrivateChannel("user.90"),
        new PrivateChannel("user.group.some_group"),
    ];
}

Upvotes: 9

Related Questions