Reputation: 423
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
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