Saturday, March 24, 2012

Push to all user?

Hi all

It's my first visit to this forum and I must say it's a great job you all do for helping each others.

I'm also new to Atlas and want to build something that can push information to the user, and i wounder if atlas can help me.

I want to start a clock that count down from 1 minute to 0. When a user make a post that trigger this function. And I want all user that browsing the site see the exactly same countdown. And if another user hit a button it will restart and countdown from 1 minute again. Is this possible in Atlas, or were should i search for information to find the soulotion for this.

Cheers Johan

Well the problem is that you cannot send a response to the browser unless the browser has issued a request. Hence if you want to get information from the server without a user actually actively requesting something, you will need to use javascript to make repeated calls to the server (via XmlHttpRequest object) and handle the request.

The non-Atlas javascript function to use would be setTimeout() and XmlHttpRequest manually.

However, since you are using Atlas, it would make sense to use:
http://atlas.asp.net/docs/Client/Sys/Timer/default.aspx

You can then bind this to a pagemethod or web service (asmx). In your case i think an asmx would be the best solution.

The rest of the specifics of the server-side logic I'm sure you can work out ;-) The application Cache would probably be the best place to store your 'countdownLastResetAt' variable...

Hope that helps,
Carlos

No comments:

Post a Comment