我在我的项目中使用推送器。在控制台调试中当我想连接到仪表板中的通道时显示事件显示断开状态并且我没有在 javascript 应用程序上获得事件。js代码:
Echo.private(`order.${orderId}`)
.listen('NewChat', (e) => {
console.log(e.message);
}
);
广播配置:
PUSHER_APP_ID=625***
PUSHER_APP_KEY=bcd15f3d3c6*******
PUSHER_APP_SECRET=c8e7e09d21********
PUSHER_APP_CLUSTER=ap2
bootstrap.js:
import Echo from 'laravel-echo'
window.Pusher = require('pusher-js');
window.Echo = new Echo({
broadcaster: 'pusher',
key: 'bcd15f3d3***********',
cluster: 'ap2',
encrypted: false
});
事件:
public function broadcastOn()
{
return new PrivateChannel('order.'.$this->order_id);
}
渠道:
Broadcast::channel('order.{orderId}', function () {
return true;
});