我正在研究需要实时广播纬度和经度的项目
我有类似下面的东西
namespace App\Events;
use App\Events\Event;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Support\Facades\Redis;
class TrackersBroadcast extends Event implements ShouldBroadcast
{
public $lat, $lng,$imei,$date_time
use SerializesModels;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct(
$lat,
$lng,
$imei,
$date_time
)
{
$this->lat = $lat;
$this->lng = $lng;
$this->imei = $imei;
$this->date_time = $date_time;
}
/**
* Get the channels the event should be broadcast on.
*
* @return array
*/
public function broadcastOn()
{
return ['tracker-channel']; …Run Code Online (Sandbox Code Playgroud) Lumen的文档指出:“ Lumen开箱即用地支持多个广播驱动程序:Pusher,Redis和log用于本地开发和调试的驱动程序。每个驱动程序均包含一个配置示例。BROADCAST_DRIVER配置选项可用于设置默认驱动程序。”
在我的.env文件中,我已设置BROADCAST_DRIVER=pusher。我在哪里/如何配置我的推送程序ID,密钥和机密?我看到在Laravel中有一个用于设置这些选项的配置文件config/broadcasting.php。我在流明的哪里可以设置这些选项?
暂时,我已经编辑Illuminate\Broadcasting\BroadcastManager并硬编码了我的值。
protected function createPusherDriver(array $config)
{
// override
$app_id = 'hidden';
$key = 'hidden';
$secret = 'hidden';
return new PusherBroadcaster(
new Pusher($key, $secret, $app_id, Arr::get($config, 'options', []))
);
}
Run Code Online (Sandbox Code Playgroud) 我正在开发 Laravel 应用程序,我需要实现广播功能。官方文档https://laravel.com/docs/7.x/broadcasting建议了3种方式:
到目前为止,我已经尝试仅使用 Pushes.com 解决方案作为最简单的解决方案。在我的睾丸上,该解决方案向用户浏览器发送消息,延迟约 1 秒。但1秒对我来说太长了。
我正在开发一个 Laravel 应用程序。我在我的应用程序中使用 Laravel Broadcast。我现在想做的是测试 Laravel 中是否广播了一个事件。
我正在广播这样的事件:
broadcast(new NewItemCreated($item));
Run Code Online (Sandbox Code Playgroud)
我想测试该事件是否被广播。我该如何测试它?我的意思是在单元测试中。我想做类似的事情
Broadcast::assertSent(NewItemCreated::class)
Run Code Online (Sandbox Code Playgroud)
该事件在创建项目时触发的观察者事件中广播。
我正在尝试在数据更改时向用户发送广播通知。但是每次我尝试发送通知时,都会收到此错误:
array_key_exists(): The first argument should be either a string or an integer.
这是我的通知:
class MyNotification extends Notification
{
use Queueable;
public $games;
public $title;
public $summary;
public $url;
public function __construct($games)
{
$this->games = $games;
$this->title = "Your games";
$this->summary = "Games for {$games[0]->team}";
$this->url = "/some/url";
}
public function via($notifiable)
{
return ['mail','broadcast','database'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return …Run Code Online (Sandbox Code Playgroud) broadcast laravel laravel-echo laravel-notification laravel-broadcast