| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- namespace App\Events;
- use App\Models\Message;
- use Illuminate\Broadcasting\InteractsWithSockets;
- use Illuminate\Broadcasting\PrivateChannel;
- use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
- use Illuminate\Foundation\Events\Dispatchable;
- use Illuminate\Queue\SerializesModels;
- class Streaming implements ShouldBroadcastNow
- {
- use Dispatchable, InteractsWithSockets, SerializesModels;
- public readonly string $chunk;
- public readonly int $index;
- /**
- * Create a new event instance.
- */
- public function __construct(private readonly Message $message, string $chunk, int $index)
- {
- $this->chunk = $chunk;
- $this->index = $index;
- }
- /**
- * Get the channels the event should broadcast on.
- *
- * @return array<int, \Illuminate\Broadcasting\Channel>
- */
- public function broadcastOn(): array
- {
- return [new PrivateChannel('App.Models.Message.' . $this->message->id)];
- }
- public function broadcastAs(): string
- {
- return 'Streaming';
- }
- }
|