laravel / reverb

Laravel Reverb provides a real-time WebSocket communication backend for Laravel applications.
https://reverb.laravel.com
MIT License
1.05k stars 76 forks source link

Dispatch events when channel subscriptions are created and destroyed. #238

Closed joekaram closed 1 month ago

joekaram commented 1 month ago

This PR adds two events:

  1. User subscribing to channel
  2. User unsubscribing from channel
taylorotwell commented 1 month ago

Please provide an explanation of what this feature could be used for.

joekaram commented 1 month ago

I have a use case, discussion, in which I would like to have the channels that have active connections, accessible from other processes.

I tried creating a Redis channel manager, that implements ChannelManager and ChannelConnectionManager contracts:

Therefore, I added the two events so I can listen to them and manage a copy of those connections, outside of the framework, to serve my purpose.

If there's any other suggestion or way to achieve this, would really appreciate it!!