开发者

How do sites like Swoopo or Quibids keep the timer with all gamers

I am always curious how different sites function.

I am assuming the site in general can be built purely in PHP and javascript and that the timer is basically running on an ajax call but how does the internal server/client machine keep everybody's computers in sync at the same time (especially given JS is a client-side language)?

If it is in fact making ajax calls (apparently every 1/5 of a second) in order to keep up with the bidding/timer settings, what type of hardware and bandwidth does a site like that have to maintain?

Are there better languages for sites like these in reality?

Thanks ahead of time!

Update

开发者_运维技巧I am not asking how to create a display of a countdown in JS ultimately - how does the relay back and forth take place between the two (server and end user)


They use the server's time and then output it to the client.

wherein the javascript then decrements it the same on each client.

This is no hit on the server. the decrement is on the client side, not on the server, as in it is not an ajax call.

for example:

var serverTime = getServerTime();

setTimeout(function(){serverTime--;},1000); 
//decrement by one every 1000 milliseconds (1 second)

And on each of those sites there could be a Comet (or any other long polling) in the background that when there is a change, the getServerTime() is called again.

This is not much of a hit on the server, like for example with Comet programming it is a hidden iframe that would call js scripts when they are needed.

see here:

Comet and jQuery

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜