Итак, у меня есть laravel echo setup, класс уведомлений, и я слушаю канал App.User. {Id} на стороне клиента, однако всякий раз, когда я слушаю уведомления, я ничего не получаю. Мой laravel эхо-сервер работает;
[18:11:06] - Preparing authentication request to: http://localhost:3000
[18:11:06] - Sending auth request to: http://localhost:3000/broadcasting/auth
[18:11:07] - HTQYvo_jRsIn9YNbAAAE authenticated for: private-App.User.1
[18:11:07] - HTQYvo_jRsIn9YNbAAAE joined channel: private-App.User.1
Мой NotifyUser.class
class NotifyUser extends Notification implements ShouldQueue, ShouldBroadcast
{
public function via($notifiable)
{
return ['database', 'broadcast'];
}
public function toBroadcast($notifiable)
{
return new BroadcastMessage([
'notification' => 1,
'message' => $this->message,
'orderId' => $this->orderId
]);
}
}
Мой интерфейс:
import Echo from "laravel-echo";
window.io = require('socket.io-client');
window.Echo = new Echo({
broadcaster: 'socket.io',
host: window.location.hostname + ':6001'
});
Прослушивание уведомлений:
Echo.private(`App.User.${this.user.id}`)
.notification((notification) => {
console.log(notification);
});
Мой слушатель очереди:
vagrant@homestead:~/code/ProjectTest$ php artisan queue:listen
[2020-03-11 16:11:18][119] Processing: App\Notifications\ProjectTest\NotifyUser
[2020-03-11 16:11:18][119] Processed: App\Notifications\ProjectTest\NotifyUser
[2020-03-11 16:11:20][120] Processing: App\Notifications\ProjectTest\NotifyUser
[2020-03-11 16:11:20][120] Processed: App\Notifications\ProjectTest\NotifyUser
[2020-03-11 16:11:21][121] Processing: Illuminate\Notifications\Events\BroadcastNotificationCreated
[2020-03-11 16:11:21][121] Processed: Illuminate\Notifications\Events\BroadcastNotificationCreated