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
+42
View File
@@ -0,0 +1,42 @@
<?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,
];
}
}