开发者

AsynchCallback function on page vs Jquery rendering .Net with live information

I am looking for some inputs and advise, I think i know what i want, but i would like to reconfirm before going ahead.

I stumbled across MarketWatch.com and i see some articles on that web site with some stocks listed in different regions of the page and they are ticking up or down with l开发者_开发技巧ive information as each second passes by.

Now I think there are few ways to achieve that ( I might be wrong with my assumption, but i am looking for to be corrected.)

The easiest way would be to call Jquery Ajax:Post function and then with result using jquery selector tag update all the stock ticks on the page, and assuming that i would like to seperate out the logic and traverse dom and update the stock quotes in respective regions.

Now this Jquery function have to do a post every 2 seconds or say 5 seconds till the page is closed by the user, Frankly i am not liking the fact that every 2 seconds i am pinging the server or service that contains the updates of stocks and manipulating Dom again (I dont think i could get away with this manipulation in my other work around as well).

I think another workaround by avoiding Jquery and then writing Server Side listener that does reverse callbacks to client browser using AynchPattern could be a way to implement it. But i am not sure how to do this. I know in old COM/DCOM says there were concepts of Stubs/proxy callback mechanism and then i think same also exist in .Net, But i want to know and learn more about how to bypass(from Browser --> to Server approach) and adopt (Server ---> to browser approach)

Please not that I am using .Net , C# on a windows platform. I know that Node.js could do that on Linux.

Any help and links to small examples would be appreciated.

Thanks

Sweety


Take a look at the socket.io client implementation and how it does long polling. This may be the solution you're looking for. Note that this may cause the little loading spinner to always be active for your users, not sure if this is true though.

/fyi #node.js IRC welcomes you: http://bit.ly/nodeIRC


If you want to stay with .net and C#, I would suggest taking a look at AspComet and using a comet client library in your client side code. You still need something feeding the updated information to AspClient. For one project I modified AspComet to respond to HTTP requests (from Twilio actually) and iject messages that the existing code would deliver to the browser. You could do the same with a DCOM/MSMQ solution or similar.

Node.js also runs on Windows and will be officially supported soon and I'll second DTrejo's invitation to join us on IRC.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜