Question

Is there any way to get the current members of a channel when authenticating a user server-side for a presence channel in Pusher?

I need this to check if the user already subscribed to the channel, so a user can't connect from two browser tabs. Is this doable?

Was it helpful?

Solution

You can query the existing users on a presence channel via the REST API: http://pusher.com/docs/server_api_guide/interact_rest_api#presence-users (bottom of page)

Note: If you give a user the same user_id as part of the authentication process then this will stop the user being shown twice in a presence channel even if they are connected via two tabs. This is because Pusher uses the user_id as a unique ID so won't count the subscription as a new user joining the channel.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top