Photo by QuinceCreative on Pixabay

An Auction Runs by A Clock

Browser Times Cannot Be Trusted

A Central Clock is Needed

Photo by geralt on Pixabay
Photo by geralt on Pixabay

Implementing a Central Clock

Node.js

Server-Side

Front-End Event-Based

socket.on('advanceCall', (data) => {});
socket.on('startAuction', (data) => {});

Front-End Periodic

socket.on('time', (data) => {});

Laravel

Server-Side

$timer = $loop->addPeriodicTimer($time, function() 
use(&$task) {
broadcast(new TimeSignal(json_encode(...)));
});
$timer = $loop->addTimer($time, function() 
use(&$task) {
broadcast(new AuctionCall(json_encode(...)));
});

Front-End

window.Echo.channel('auction-events')
.listen('startAuction', (e) => {

});
window.Echo.channel('time-signal')
.listen('time', (e) => {

});

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Yoram Kornatzky

Yoram Kornatzky

254 Followers

Entrepreneur, Building: Auction Events Platform for Creators, 25 years of development experience, Ph.D. Computer Science, https://yoramkornatzky.com