mirror of
https://github.com/ericasch6/scrum-poker-internal.git
synced 2026-10-13 16:52:08 +00:00
44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Events;
|
|
|
|
use Illuminate\Broadcasting\Channel;
|
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
|
use Illuminate\Foundation\Events\Dispatchable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class PaperBallThrown implements ShouldBroadcastNow
|
|
{
|
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
|
|
|
public function __construct(
|
|
public readonly string $id,
|
|
public readonly string $roomId,
|
|
public readonly int $fromPlayerId,
|
|
public readonly int $targetPlayerId,
|
|
) {}
|
|
|
|
public function broadcastOn(): Channel
|
|
{
|
|
return new Channel("rooms.{$this->roomId}");
|
|
}
|
|
|
|
public function broadcastAs(): string
|
|
{
|
|
return 'room.emote.thrown';
|
|
}
|
|
|
|
/**
|
|
* @return array{id: string, from_player_id: int, target_player_id: int}
|
|
*/
|
|
public function broadcastWith(): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'from_player_id' => $this->fromPlayerId,
|
|
'target_player_id' => $this->targetPlayerId,
|
|
];
|
|
}
|
|
}
|