mirror of
https://github.com/ericasch6/scrum-poker-internal.git
synced 2026-10-13 17:52:09 +00:00
feat: added laravel reverb and websocket, also emote throwing added
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?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,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user