푸셔로 Laravel 5.3을 사용하려고했지만 내 코드에서 올바르게 작동하지 않는 것 같습니다.Pusher and Laravel 5.3 이벤트 브로드 캐스팅
내 .env의가 올바른지
PUSHER_APP_ID= myappid
PUSHER_KEY= mykey
PUSHER_SECRET= mysecret
이 broadcasting.php 내 '푸셔'구성이다
내가 이벤트를 생성'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_KEY'),
'secret' => env('PUSHER_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => 'eu',
'encrypted' => true,
],
],
, 여기가
<?php
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
class ProposalEvent implements ShouldBroadcast
{
use InteractsWithSockets, SerializesModels;
public $data;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($data)
{
$this->data = $data;
}
/**
* Get the channels the event should broadcast on.
*
* @return Channel|array
*/
public function broadcastOn()
{
return ['test-channel'];
// return new PrivateChannel('test-channel');
// return new PresenceChannel('test-channel');
}
}
내 javascript
Pusher.logToConsole = true;
var pusher = new Pusher("mykey", {
cluster: 'eu',
encrypted: true
});
var channel = pusher.subscribe('test-channel');
channel.bind('App\\Events\\ProposalEvent', function(data) {
alert(data);
});
그리고 마지막으로 내보기에
event(new App\Events\ProposalEvent('some data'));
불행하게도이 나를 위해 작동하지 않습니다,하지만 난 이벤트없이이 같은 pusher-> 트리거를 사용할 때, 그것은 잘 작동하고 난 푸셔 디버그 콘솔
에 메시지가 표시$options = array(
'cluster' => 'eu',
'encrypted' => true
);
$pusher = new Pusher(
'mykey',
'mysecret',
'myid',
$options
);
$data['message'] = 'some data';
$pusher->trigger('test-channel', 'my-event', $data);
나는 Laravel 문서 및 기타 리소스에서 해결책을 찾았습니다. stackoverflow 같은 문제가 있지만 응답이 없습니다. 몇 일 동안 해결책을 찾을 수 없기 때문에 누군가가 나를 도울 수 있다면 감사 할 것입니다.