1

My question is about real time collaboration between users in a django powered web site.

In practice what I need to know is if it's possible to implement such a system: 1) Say that all users using the web site are user1, user2, ... userN 2) Each time one of the users do something interesting notify the server and other users in order to update the application status and the browsers ui 3) The previous point can be extended to cover not only user-triggered events but also other more general events like timeouts, or "every 5 minutes" or what ever you can imagine.

I know that browser to server and server to browser communication can be done via ajax (or something newer like web-sockets or SSE), but the part that is obscure to me is how to notify users when a certain events occurs. The only (bad) idea that comes to mind is to store application data to database and update it when a user do something, and at the same time have all the users polling the application status from db. But I would know if there is a way to avoid the use of database and the polling system, in other words something like:

when event e is triggered => send to all browsers "e triggered"

Thanks in advance

I'll try to better explain my question: I would like to know how to send a response to user "Frank" when another user "John" do something. The problem isn't how the server send something to a browser but how to link john’s activity (i.e. click button, change page, fill forms) to Frank’s ui without using a database. For example think about a simple chat page, when a user type something the typed text must be pushed to all other users: in this case I don't know how to link the action "John typed something" with the action "send typed text to Frank's browser". The memcache solution sound good, but I would like to know if there is something else like a pub-sub or event system that can be used to link different users' connections.

4

1 回答 1

0

实现一个缓存(即memcache)以避免在Ajax 调用检查更改时访问数据库。如果您想花哨,请查看基于键的缓存过期以处理缓存失效。

于 2013-08-20T23:22:24.740 回答