Black Mask
Black Mask

Reputation: 423

how to send event to the client after specified time in web socket(pusher) Laravel?

I am beginner in Web Socket. i am building an online exam system. i already have timer coundown system.so while any student taking an exam, JavaScript sends an ajax request every second to the server, so when countdown < 0 then JavaScript reloads the page to stop exam.

but now i want to achieve this functionality with web socket. how to broadcast an event to the clients when the specified time passed.i am using pusher with laravel.

Upvotes: 0

Views: 720

Answers (1)

r00t
r00t

Reputation: 466

In Your Exam model add started_at attribute. Then make function which will run every minute (https://laravel.com/docs/5.7/scheduling#introduction) and check if time is expired. If it is just send an event to client using Pusher and reload the browser

Upvotes: 1

Related Questions