initial commit
This commit is contained in:
commit
e8c3f9862a
193 files changed
+29795
No files matched your search
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
|
||||
/**
|
||||
* Tells a client why its room control frame was rejected (e.g. joining a
|
||||
* room that does not exist). Broadcast to game.{room}, which the requesting
|
||||
* client is already subscribed to.
|
||||
*/
|
||||
final class GameRoomError implements ShouldBroadcastNow
|
||||
{
|
||||
use Dispatchable;
|
||||
use InteractsWithSockets;
|
||||
|
||||
public function __construct(
|
||||
public readonly string $room,
|
||||
public readonly string $code,
|
||||
) {}
|
||||
|
||||
public function broadcastOn(): Channel
|
||||
{
|
||||
return new Channel('game.'.$this->room);
|
||||
}
|
||||
|
||||
public function broadcastAs(): string
|
||||
{
|
||||
return 'room-error';
|
||||
}
|
||||
|
||||
/** @return array{code: string, room: string} */
|
||||
public function broadcastWith(): array
|
||||
{
|
||||
return [
|
||||
'code' => $this->code,
|
||||
'room' => $this->room,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user