简体   繁体   English

如何使用django-rest-framework作为后端和angular2作为前端实现推送消息的websocket?

[英]How to implement websocket for push message using django-rest-framework as backend and angular2 as frontend?

  • I want to implement websocket to send push notification to client. 我想实现websocket将推送通知发送到客户端。
  • I am using django-rest framework as backend and angular2 as frontend. 我正在使用django-rest framework作为后端,而angular2作为前端。
  • I know that django support HTTP protocol only. 我知道django仅支持HTTP协议。 And I am unable to get any such links,blogs or resource which helps me to achieve websocket completely. 而且我无法获得任何此类链接,博客或资源来帮助我完全实现websocket。
  • Currently I am using polling from frontend. 目前,我正在使用前端轮询。
  • There are some third party apps which I found and may be useful for implementing push message. 我发现了一些第三方应用程序,这些应用程序可能对实现推送消息有用。 They are... 他们是...

    pywebsocket pywebsocket

    tornado 龙卷风

    Django Channels Django频道

  • I don't think showing some code is significant here because i have no code relevent to implementation of websocket. 我认为在这里显示一些代码并不重要,因为我对实现websocket没有任何代码依赖性。

  • So can you people suggest me the best way to implement this thing.Any link,any blog or any code which may help. 因此,您能否向我建议实现此问题的最佳方法。任何链接,任何博客或任何可能有帮助的代码。

One possible solution is to deploy a separate Tornado app which communicates with Front-end using WebSocket . 一种可能的解决方案是部署一个单独的Tornado应用程序,该应用程序使用WebSocket与Front-end通信。 Then, whenever the Django Back-end wants to send a push notification to the Front-end, it asks the Tornado app and Tornado app delivers the push notification to Front-end. 然后,每当Django后端希望将推送通知发送到前端时,它都会询问Tornado应用,然后Tornado应用会将推送通知传递到前端。

I have described the process in slightly more detail in this answer of mine. 我已经描述了稍微详细过程这个回答我的。 You might want to have a look. 您可能想看看。

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

相关问题 如何使用django只有一个后端并使用django-rest-framework发布 - How to use django only a backend and post with django-rest-framework 使用Django-Rest-Framework发布后的角度刷新列表 - Angular refresh list after post using Django-Rest-Framework Angular 2 前端 django 2 REST 框架后端用户身份验证 - Angular 2 frontend django 2 REST framework backend user auth 在Heroku上使用Django Rest Framework后端部署Angular 4前端 - Deploying an Angular 4 frontend with a Django Rest Framework backend on Heroku 在django-rest-framework中添加警告消息 - Add warning message in django-rest-framework 在 django-rest-framework 中验证 javascript 前端的好方法 - A good way to authenticate a javascript frontend in django-rest-framework 如何使用django-rest-framework保存外键 - how to save foreign keys using django-rest-framework 如何使用django-rest-framework序列化ValuesQuerySet? - How to serialize a ValuesQuerySet using django-rest-framework? 如何使用django-rest-framework和angularJS注册用户? - How to register users using django-rest-framework and angularJS? Django REST 框架 - 如何在前端事件发生后在后端启动函数 - Django REST Framework - how to start functions on backend after event on frontend
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM