-
-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subscription send only to others #2293
Comments
Possible easier solution number 2We know that Laravel uses And you have accessed public function authorized(Request $request): JsonResponse
{
$userId = md5(
$request->input('channel_name')
. $request->input('socket_id')
); So what if the Subscriber in filter function did contain the public function filter(Subscriber $subscriber, $root): bool
{
return $subscriber->socket_id !== request()->input('socket_id');
} Obviously we could make it a little better in terms of usage (Extracting it to a function in parent and call that in a more elegant way) but this is just a concept for now. How to implementAgain traced just by my eyes, we can change this class (Obviously)
And also it is filled only in one place:
|
I never really worked with subscriptions and do not plan to work on it myself, but I am open for pull requests. |
Thanks for letting me know, I did manage to make it work also did a PR at #2298 |
https://laravel.com/docs/9.x/broadcasting#only-to-others
I think it is a really nice feature to have and it should be very simple to achieve it, since it's only a ready function that needs to be called.
What problem does this feature proposal attempt to solve?
When building an application that utilizes event broadcasting, you may occasionally need to broadcast an event to all subscribers to a given channel except for the current user.
Which possible solutions should be considered?
I think this feature is only for the Laravel Echo's broadcaster searching in your codebase I think I found where that method should be added:
lighthouse/src/Subscriptions/Broadcasters/EchoBroadcaster.php
Line 26 in 8756e1e
I noticed the autocompletion working there making this possible:
Let me share my findings (haven't actually run the code just looked for now), this is the trace I did:
Going in:
queue's job calls
$broadcaster->broadcast
again internally so let's see:Which leads to:
and there we find the echo driver:
Inside that we'll reach
lighthouse/src/Subscriptions/Broadcasters/EchoBroadcaster.php
Line 26 in 8756e1e
So that should be it, we could pass along some data to the Queue Job and the other one, for an extra
$toOthers
and that can be used, it sounds like a pretty important feature that I still doubt whether this is already implemented and I missed it, nevertheless let me know what you think.The text was updated successfully, but these errors were encountered: