Skip to content
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

Presence channel inconsistencies #213

Closed
stefanvdlugt opened this issue Jun 21, 2024 · 3 comments · Fixed by #216
Closed

Presence channel inconsistencies #213

stefanvdlugt opened this issue Jun 21, 2024 · 3 comments · Fixed by #216
Assignees
Labels

Comments

@stefanvdlugt
Copy link

Reverb Version

1.0.0-beta13

Laravel Version

11.8.0

PHP Version

8.2.18

Description

We are trying to migrate from Pusher to Laravel Reverb with Laravel Echo and encountered some inconsistent behavior.

In Pusher, the member_added event is triggered whenever a user joins a channel. However, if the same user has multiple tabs open, this event triggers only for the first tab. Likewise, the member_removed event only triggers once a user has closed all their connections. See the Pusher documentation where this behavior is documented.

In Reverb, however, these events seem to trigger each time a user connects or disconnects to a presence channel. This makes it impossible to keep track of who is present. For example, if user A has one tab open, and user B two tabs, and user B closes one of the two tabs, user A receives a message that user B left. When user A refreshes the page, they do see that user B is present again.

Is this change of behavior intentional? If so, what would be the right way of keeping track of users with multiple tabs?

Steps To Reproduce

Echo.join(nameOfPresenceChannel)
    .here((users) => {
        console.log(users);
    })
    .joining((user) => {
        console.log(user.name + ' has joined');
    })
    .leaving((user) => {
        console.log(user.name + ' has left');
    })
  1. Open one tab as user A and open the console log
  2. Open two tabs as user B. User A will see that user B has joined.
  3. Close one tab as user B. User A will see that user B has left (even though user B still has a tab open)
  4. Refresh the tab with user A. User A will see that user B is actually still there.
@stefanvdlugt
Copy link
Author

I realized that the behavior of the subscription_succeeded event is also different.

On the Pusher side, the message contains a array of unique user IDs. On the Reverb side, the same user ID can appear multiple times if that user has multiple connections open.

@joedixon
Copy link
Collaborator

Just had a quick glance and think I can see where this is happening. I will try and take a look into this next week.

@joedixon
Copy link
Collaborator

Hey @stefanvdlugt would you mind taking this PR for a spin and seeing if it resolves your issue?

#216

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants