feat: added laravel reverb and websocket, also emote throwing added

This commit is contained in:
2026-08-16 17:10:42 +02:00
parent 50e9fbd0b0
commit 6f47ed0674
30 changed files with 2244 additions and 34 deletions
+43
View File
@@ -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,
];
}
}