开发者

How to calculate scheduled time calculation for each user on the server side and instantly notify it to respective user on the client side?

My scenario is

User A has been given a task. He already knows time line for that task.On client side Once the userA click and download a file to begin that task ,server should do some kind of timers and notify client user A about the remaining due time instantly.

so that user can aware of the decreaseing time of his/her task.

In future there may be hundred's of user can connect with server and has to acheive the above scenario.All time related calultion is based on server current time

can anybody g开发者_开发问答uide me on how to implement this.


Salaam,

You need to implement a timer at your Servlet, per each user.

Care about the following:

  • Knowing that a servlet is multi-threaded, dont store the timer on a global variable (scope of servlet/all threads), but on local variable(scope of request/thread)
  • declare the initial time variable at servlet init and as global variable.
  • The timer stores the value (current - user.start - initial) in the request.session specific to the user
  • the timer can be updated via ajax from client side

Hope it helps,

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜