简体   繁体   English

龙卷风,Django和推送通知

[英]Tornado, Django, and push notifications

I've searched Stack overflow and all I can find is how to use Tornado as a HTTP server. 我搜索了Stack溢出,我所能找到的是如何使用Tornado作为HTTP服务器。

Now, my question is how do I start doing push notifications using the system? 现在,我的问题是如何开始使用系统进行推送通知?

Let me give you some context... 让我给你一些背景......

The database 数据库

I have a database on some server far away that I know nothing about, other than its a postgreSQL database and a piece of software on that server updates the database every so often ( maybe every couple of seconds, to couple of days). 我在远处的某个服务器上有一个我不知道的数据库,除了它的postgreSQL数据库和该服务器上的一个软件经常更新数据库(可能每隔几秒,几天)。

Currently 目前

I Have a django app that displays these database rows. 我有一个显示这些数据库行的django应用程序。 it gets these database rows from a different app - an app called api - using an ajax call every 5 seconds. 它从一个不同的应用程序 - 一个名为api的应用程序 - 每隔5秒使用一次ajax调用获取这些数据库行。 As we all know this method is wasteful. 众所周知,这种方法很浪费。

What I'd like to do 我想做什么

Well I'll bullet point it: 好吧,我会指出它:

  1. I'd like my Django app to stay the same in structure 我希望我的Django应用程序在结构上保持不变
  2. The Django app will contain in its view JS code for connecting to a separate server. Django应用程序将在其视图中包含用于连接到单独服务器的JS代码。
  3. this separate server will check the database for changes every 60 seconds. 这个单独的服务器将每隔60秒检查数据库是否有变化。 If the database has changed, then notify the clients with a message, such as "new data available" 如果数据库已更改,则通过消息通知客户端,例如“可用的新数据”

Hopefully thats not too vague. 希望那不是太模糊。

Thanks, 谢谢,

Andy. 安迪。

I found that the django-websocket-redis package suits my needs which are very much comparable to yours as it can easily be implemented on top of your existing project. 我发现django-websocket-redis软件包适合我的需求,与您的需求非常相似,因为它可以很容易地在现有项目之上实现。

Mind that there are a few dependencies (UWGSI and Redis, primarily) and I've had to switch to a Linux development environment to get everything to work properly. 请注意,有一些依赖项(主要是UWGSI和Redis),我不得不切换到Linux开发环境,以使一切正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM