If you use Pusher, the backend can simply do the following:
$response = $pusher->get( '/channels/presence-channel-name/users' );
if( $response[ 'status'] == 200 ) {
$users = json_decode( $response[ 'body' ], true )[ 'users' ];
}
$userCount = count($users);
You can read more about this in the documentation. pusher-http-php sdk also has some documentation for this.
, , /channels/[channel_name]/users, channel_name .
.
, webhooks.
, . , , .
Pusher :
{
"name": "member_added", // or "member_removed"
"channel": "presence-your_channel_name",
"user_id": "a_user_id"
}
, , redis.