【发布时间】:2011-09-04 06:29:40
【问题描述】:
我刚开始使用 tornado,并使用 nginx proxing tornado 和 php 进行设置,一切正常
我试图实现的是一个通知系统。
当一个用户执行诸如发送电子邮件或更新数据库中的字段等操作时,如果其他用户正在浏览网页,他会收到通知。
所以我会使用 jquery ajax 将消息和用户名发送到 tornado。 我得到了那个部分的工作。例如:
$.ajax({url: "/send/notification", data: "data//Serialise from form , dataType: "text", type: "POST",
success: function(response) {
alert("Message From Tornado : "+response);
}, error: function(response) {
console.log("ERROR:", response)
alert("Failed");
}});
然后在 Tornado 上获取收件人的姓名
recipient = self.get_argument("recipient", None)
现在使用 jquery ajax 函数长轮询 tornado 以获得响应。 但是我完全迷失了如何让龙卷风检查该通知是否适合他,如果是的话,请向他发送数据。
类似
if self.current_user == recipient:
self.write(some data);
任何帮助将不胜感激
【问题讨论】: