Reverse Ajax(Comet) with ASP.NET
I am looking for a basic example of how to implement the Reverse Ajax (Comet) with ASP.NET. I have already looked the below ones and I don't want t开发者_如何学Co use them right now (because they are paid)
http://www.frozenmountain.com/websync/ http://www.lightstreamer.com/demos.htm
I have already gone on various links mentioned on SO . But most of them are pointing towards external API. I am looking for a clear cut example of how to implement that .
Unfortunately you will not find one. Reverse Ajax is a complex task that requires both server side and client side "magic" in order to be cross-browser compatible, have proper state and thread management and be scalable. Essentially a comet server is a streaming connection per client (or long polling) + clever thread management. In addition for a proper comet server you would have to fully implement the Bayeux protocol.
There is an article on CodeProject on how you can implement something like that in IIS, but even that is immensely complex.
We've considered implementing something of our own but quickly decided against that, since that would cost us months of work, so those products come out really cheap.
Also, if you are really interested on how to implement something like that the best place to start would be to dig into WebSync source code, since it's not obfuscated. Be careful with plagiarism though as they have quite a few unique know-hows in there.
Another option is to consider other platforms (open source comet servers in other languages). You may find them to be a lot more suitable for the task than C#. For instance, you will find writing a comet server in erlang to be dead easy.
EDIT: There are actually already two great similar questions on SO that might help you: Comet implementation for ASP.NET? and Simple “Long Polling” example code?
have a look at http://pokein.codeplex.com/
Take a look at SignalR, it's free, very easy to use and works well.
https://github.com/SignalR/SignalR
Scott Hanselman talks about it in his blog too
I have been looking for the same thing and I found https://github.com/nmosafi/aspComet which is opensource (you can contribute to it if you would like). They have a working sample on the site that you can have a look at. They have a guy who blogs about some of the design decisions etc that you may find useful (Blog Link)
Please see this S.O. question if you're willing to consider Silverlight PollingDuplexHttpBinding as a way to link Javascript to your server.
精彩评论