So i need to develop a messaging wall.

所以我需要开发一个消息传递墙。

What this means is i have a page where users can post data too, so for example they can post "Hello, how are you?". This then would get submitted to all relevant users...

这意味着我有一个用户也可以发布数据的页面,例如他们可以发布“你好,你好吗?”。然后将提交给所有相关用户......

The way i have this currently setup is as follows:

我目前设置的方式如下:

User visit page, a function is run to pull all the current wall messages from the database and display it on the screen using an AJAX call... Through jQuery, I then use the set_interval function to run the same function above every 1 second. This is so that the information on the message window is current. As well, if a user posts something to wall, this very same update function is called.

用户访问页面,运行一个函数来从数据库中提取所有当前的挂壁消息并使用AJAX调用将其显示在屏幕上...通过jQuery,我然后使用set_interval函数每1秒运行一次相同的函数。这样消息窗口上的信息是最新的。同样,如果用户将某些内容发布到墙上,则会调用相同的更新功能。

This way everything is always up to date, or about to be up to date in at most 1 seconds time.

这样一切都始终是最新的,或者即将在最多1秒的时间内保持最新状态。

So I'm sure most of you are thinking, well what's the problem... The problem is that the server will receive a request every 1 second for every user that is on the message page for as long as they are on the message page. So it adds some unwanted stress to the server.

所以我相信你们大多数人都在思考,问题是什么......问题是,只要消息页面上的每个用户都在服务器上每隔1秒收到一个请求。所以它给服务器增加了一些不必要的压力。

Is there any way for me to have the server notify the user when there is any changes to the message wall, as opposed having the current system?

当消息墙有任何变化时,有没有办法让服务器通知用户,而不是当前的系统?

1 个解决方案

#1


0

When you need to keep long user connection for informing him about events immediately, then you probably need some async approaches. And they will use websockets.

当您需要保持长时间的用户连接以立即通知他事件时,您可能需要一些异步方法。他们将使用websockets。

In python you can choose Tornado.

在python中你可以选择Tornado。

And at client size one of the best choice is SockJS.

在客户规模上,最好的选择之一是SockJS。

Also, there is possibility to process async task by Tornado, and other web site will work with django. In that case you'll need to implement communication between tornado and django. It could be done using queues.

此外,Tornado可以处理异步任务,其他网站也可以使用django。在这种情况下,您需要实现龙卷风和Django之间的通信。它可以使用队列完成。

Take a look at centrifuge project. This project use Tornado, SockJS.

看看离心机项目。这个项目使用Tornado,SockJS。

更多相关文章

  1. 用户输入从.csv文件生成新列表?
  2. Cloud Pub / Sub Demo:403未授权用户执行此操作。当试图推送通知
  3. Django EventLog:传入当前用户
  4. Python基础--图形用户界面GUI
  5. Python脚本如何获取当前环节和用户等信息
  6. Django 1.5多用户身份验证或
  7. pylogin系列之V2EX自动领币消息提醒
  8. python接入微博第三方API之2接入用户登录和微博发布
  9. linux修改文件所属用户和组

随机推荐

  1. 内核版本与Android版本对应关系
  2. Android网络请求框架AsyncHttpClient详解
  3. android项目在不同平台切换的问题
  4. Android(安卓)安全机制
  5. Android(安卓)adb 命令大全
  6. Android(安卓)Content Provider[转]
  7. Android事件分发机制详解(二)
  8. Android(安卓)客户端与服务器端进行数据
  9. android(18)_数据存储与访问_SQLite数据
  10. 解决Android(安卓)4.2.2 脱机(offline)问