Probably better to use broadcast events instead of queues.
php artisan make:event QuestionStarted
Then make the event broadcast to a public or private channel and use Laravel Echo to listen to the event when a person is present in that channel.
The below example assumes you are publishing events to a private lobby with the ID of 1
<?php
namespace App\Events;
use App\Models\Question;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Queue\SerializesModels;
class QuestionStarted implements ShouldBroadcast
{
use SerializesModels;
public $question;
public function __construct(Question $question)
{
$this->question = $question;
}
public function broadcastOn()
{
return new PrivateChannel('lobby_' . 1);
}
}
Then listen for the event
Echo.channel(`lobby_1`)
.listen('QuestionStarted', (e) => {
console.log(e.question);
});
From here you can use set timeout or set interval in Vue.js to make axios requests to controllers or routes that fire these events as you wish