implement powerful viewer count system
This commit is contained in:
@@ -10,6 +10,8 @@ use Illuminate\Support\Str;
|
||||
|
||||
class MediaMtxService
|
||||
{
|
||||
public function __construct(private readonly ViewerCountStore $viewerCounts) {}
|
||||
|
||||
public function authorize(array $payload): bool
|
||||
{
|
||||
$action = (string) ($payload['action'] ?? '');
|
||||
@@ -79,6 +81,8 @@ class MediaMtxService
|
||||
'live_broadcast_id' => $broadcast->id,
|
||||
])->save();
|
||||
|
||||
$this->viewerCounts->forget($channel);
|
||||
|
||||
return $broadcast;
|
||||
}
|
||||
|
||||
@@ -107,6 +111,8 @@ class MediaMtxService
|
||||
'live_broadcast_id' => null,
|
||||
])->save();
|
||||
|
||||
$this->viewerCounts->forget($channel);
|
||||
|
||||
return $broadcast;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user