StreamStart.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace App\Events\LiveStream;
  3. use Illuminate\Broadcasting\Channel;
  4. use Illuminate\Broadcasting\InteractsWithSockets;
  5. use Illuminate\Broadcasting\PresenceChannel;
  6. use Illuminate\Broadcasting\PrivateChannel;
  7. use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
  8. use Illuminate\Foundation\Events\Dispatchable;
  9. use Illuminate\Queue\SerializesModels;
  10. class StreamStart implements ShouldBroadcast
  11. {
  12. use Dispatchable, InteractsWithSockets, SerializesModels;
  13. public $id;
  14. /**
  15. * Create a new event instance.
  16. *
  17. * @return void
  18. */
  19. public function __construct($id)
  20. {
  21. $this->id = $id;
  22. }
  23. /**
  24. * Get the channels the event should broadcast on.
  25. *
  26. * @return \Illuminate\Broadcasting\Channel|array
  27. */
  28. public function broadcastOn()
  29. {
  30. return new Channel('live.chat.' . $this->id);
  31. }
  32. public function broadcastAs()
  33. {
  34. return 'stream.start';
  35. }
  36. public function broadcastWith()
  37. {
  38. return ['ts' => time() ];
  39. }
  40. }