| 12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- namespace App\Events;
- use Illuminate\Broadcasting\Channel;
- use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
- class BroadcastToStation implements ShouldBroadcastNow
- {
- public $json;
- private $id;
- const ALL_STATION=0;
- /**
- * Create a new event instance.
- *
- * @param int $id
- * @param string $json
- * @return void
- */
- public function __construct(int $id, string $json)
- {
- app('LogService')->log('海柔','broadcast1',$id.$json);
- $this->id = $id;// 0意味着通用站,所有站都需要收发的意思
- $this->json = $json;
- }
- /**
- * Get the channels the event should broadcast on.
- *
- * @return Channel|array
- */
- public function broadcastOn()
- {
- app('LogService')->log('海柔','broadcast2',$this->id.$this->json);
- return new Channel('station-'.$this->id);
- }
- }
|