Broadcast to private and presence channels with the same name ?
Hello,
Pusher renames each channel by prefixing it for example with private- or presence-.
In Laravel, I define the channels route. For now it doesn't work like this, but the idea would be to have the same channel name room to use for both private and presence channels.
Broadcast::channel('room', function ($user, $roomId) {
return $user->is(auth()->user());
});
Broadcast::channel('room', function ($user) {
return [
'id' => $user->id,
];
});
@vincent15000 upon reading further into the behaviour, I don't believe my suggestion would work, but let me know otherwise. I also omitted .{roomId} from the channel name so it would likely not recieve this in the second parameter.
I would suggest separating the channels like so...
Broadcast::channel('room.{roomId}', function ($user, $roomId) {
return $user->is(auth()->user());
});
Broadcast::channel('room', function ($user) {
return [
'id' => $user->id,
];
});