Creating realtime online auction and communication system for multiple users
Posted on 2015-01-10
My task is to create a realtime online auction and communication system for an auction house. They are running a floor auction, but also inviting bidders to participate online by logging into their website and "watching" the auction in realtime, with the option to place a bid, etc.
I've got the majority of this task covered. Users will login and be tracked with a session cookie. The administrator will have a special login that allows them to control the auction, specify which lot is current, enter floor bids, type communications to bidders, etc.
When the administrator (or any other user) does some action, it will send a jQuery/AJAX request to the server and update a database. So the database will always contain the current "state" of what is going on with the auction. The administrator can also send and receive private messages to/from bidders (or the whole group), those would also go to a database.
My question is: how do I best setup this app so that users can receive information in the smoothest, most "realtime" fashion possible, from a conceptual standpoint? Sending data seems like the easy part, but updating the user's screen is what I need to figure out. It seems that I am basically building a chat room, with some specific add-on capabilities related to displaying lot information and pictures, ability to place a bid, etc.
My first thought is to use timers of some kind. Have the user's computer poll the server every X number of seconds, grab the latest set of chat messages (for example), figure out if anything has changed, and if so update the user's screen. But I obviously need to account for network lag, so I can't guarantee this will happen every X number of seconds.
Is there a smoother, more modern way to accomplish this?
Also, the administrator will control a countdown, so that a lot will close in (for example) 12 seconds. Somehow the current "count" needs to be distributed to everyone who is logged in. And if a floor bid is placed, the count is reset to 12 seconds again. Should the server contain the "master" countdown? Or the administrator's computer? How best to distribute this countdown to all users?
I'm obviously not looking for code here. I think I have the skills to create this system, just looking for some advice on how best to approach this.