开发者

C# observer pattern message filtering

开发者 https://www.devze.com 2023-02-22 08:44 出处:网络
I\'m writing a video cms and want all my users开发者_开发问答 to have new assets displayed immediately as they come in.

I'm writing a video cms and want all my users开发者_开发问答 to have new assets displayed immediately as they come in. If I'm right, facebook updates its wall-page in realtime. So when I post something to a friend it immediately displays on his wall. The realtime web, as they say. I wonder how you do that? Not the technology of client-server-communication, but what goes on on the server. I understand the principles of the observer-pattern. But a wall is in fact a query on a table of messages. How does the observer know what query a user is interested in? Does it hold all the query's of all connected users and reruns it when something new comes in. I believe Google-realtime works that way to. Thank you for helping me out.


When you open facebook, open the script timeline in your browser to see what scripts are executing on the page. You'll notice that there is a polling script being executed several times a second. So the page is looking at the cache several times a second to see if there is any new information that can be displayed.

http://www.ajaxwith.com/Poll-vs-Push-Technology.html - this should give you a background on the subject.


Facebook uses AJAX and a JavaScript timer that polls in the background looking for anything that's changed. Other sites use the same type of functionality to update stock quotes embedded in the page, etc. It's not truly updating immediately, it's updating as frequently as the JavaScript timer hits their server. This is because web browsers use HTTP, which is a request/response protocol. A browser won't display anything that's not as a direct response to a request initiated by the browser; there's no way to just send content directly to the browser from your webserver.

0

精彩评论

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