mirror of
https://github.com/ericasch6/scrum-poker-internal.git
synced 2026-10-13 20:32:09 +00:00
43 lines
1015 B
PHP
43 lines
1015 B
PHP
<?php
|
|
|
|
namespace App\Events;
|
|
|
|
use App\Enums\RoomStateChange;
|
|
use Illuminate\Broadcasting\Channel;
|
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
|
use Illuminate\Foundation\Events\Dispatchable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class RoomStateChanged implements ShouldBroadcast
|
|
{
|
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
|
|
|
public function __construct(
|
|
public readonly string $roomId,
|
|
public readonly int $version,
|
|
public readonly RoomStateChange $change,
|
|
) {}
|
|
|
|
public function broadcastOn(): Channel
|
|
{
|
|
return new Channel("rooms.{$this->roomId}");
|
|
}
|
|
|
|
public function broadcastAs(): string
|
|
{
|
|
return 'room.state.changed';
|
|
}
|
|
|
|
/**
|
|
* @return array{version: int, change: string}
|
|
*/
|
|
public function broadcastWith(): array
|
|
{
|
|
return [
|
|
'version' => $this->version,
|
|
'change' => $this->change->value,
|
|
];
|
|
}
|
|
}
|