Ask Your Question
0

What is the method to obtain the number of subscribed users on a private channel in Pusher?

asked 2021-09-07 11:00:00 +0000

djk gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-06-01 10:00:00 +0000

pufferfish gravatar image

To obtain the number of subscribed users on a private channel in Pusher, you can use the pusher:subscription_succeeded event, which is triggered when a new user subscribes to a channel. You can listen for this event and keep track of the number of subscribed users on the channel.

Here's an example code snippet in JavaScript:

var channel = pusher.subscribe('private-channel');

channel.bind('pusher:subscription_succeeded', function(members) {
  console.log('Number of subscribed users:', members.count);
});

In this example, members is an object that contains the new subscription information. members.count returns the number of subscribed users on the channel.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-09-07 11:00:00 +0000

Seen: 10 times

Last updated: Jun 01 '21