38 lines
883 B
PHP
38 lines
883 B
PHP
<?php
|
|
|
|
namespace App\Events;
|
|
|
|
use Illuminate\Broadcasting\Channel;
|
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
|
use Illuminate\Foundation\Events\Dispatchable;
|
|
|
|
/**
|
|
* Intent-getriebene Aktionen vom Fox-Agent ans HUD.
|
|
* Beispiel-Payloads:
|
|
* ['action' => 'map', 'city' => 'wien', 'data' => [...city...]]
|
|
* ['action' => 'food', 'location' => 'wien']
|
|
* ['action' => 'response', 'text' => '...']
|
|
*/
|
|
class FoxAction implements ShouldBroadcastNow
|
|
{
|
|
use Dispatchable, InteractsWithSockets;
|
|
|
|
public function __construct(public array $payload) {}
|
|
|
|
public function broadcastOn(): array
|
|
{
|
|
return [new Channel('fox')];
|
|
}
|
|
|
|
public function broadcastAs(): string
|
|
{
|
|
return 'fox.action';
|
|
}
|
|
|
|
public function broadcastWith(): array
|
|
{
|
|
return $this->payload;
|
|
}
|
|
}
|