PHP code example of webpatser / resonate-channel-meter
1. Go to this page and download the library: Download webpatser/resonate-channel-meter library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
webpatser / resonate-channel-meter example snippets
use Webpatser\ResonateChannelMeter\Concerns\HasChannelMeter;
class Chat extends Model
{
use HasChannelMeter;
}
$chat->channelMeterPeriods; // every period
$chat->openChannelMeterPeriods; // periods currently in progress
$chat->totalChannelMeterSeconds(); // sum of closed durations
$chat->totalChannelMeterSeconds($from, $to); // clamped to a window
use Webpatser\ResonateChannelMeter\Http\Controllers\WebhookController;
use Webpatser\ResonateChannelMeter\Http\Middleware\VerifyPusherSignature;
Route::post('/webhooks/resonate', WebhookController::class)
->middleware(VerifyPusherSignature::class);
use Webpatser\ResonateChannelMeter\Contracts\MembershipCounter;
use Webpatser\ResonateRoster\RoomRoster;
$this->app->singleton(MembershipCounter::class, fn () => new class implements MembershipCounter {
public function count(string $channel): int
{
return (new RoomRoster(config('resonate-roster')))->userCount($channel);
}
});