I'm writing a web application using Python's twisted.web
on the server side.
我正在服务器端使用Python的twisted.web编写Web应用程序。
On the frontend side I would like to use Ajax
for displaying real time updates of events which are happening in the server.
在前端,我想使用Ajax显示服务器中发生的事件的实时更新。
There are lots of information out there on how this can be done, so I realized I need to pick a javascript library that would make my life easier.
关于如何做到这一点有很多信息,所以我意识到我需要选择一个让我的生活更轻松的JavaScript库。
socket.io
seems to be a good choice since it supports several browsers and transport mechanisms, but by reading their examples it seems it can only work with node.js
?
socket.io似乎是一个不错的选择,因为它支持几种浏览器和传输机制,但通过阅读他们的示例,它似乎只能与node.js一起使用?
So, does anyone know if it's possible to use socket.io
with twisted.web
? If so, any links for a good example/tutorial would be also welcome.
那么,有没有人知道是否可以使用twisted.web的socket.io?如果是这样的话,也欢迎任何一个好示例/教程的链接。
2 个解决方案
#1
2
You need something server side to integrate with the socket.io script on the client side. The servers that I know that are written in Python and do this all use Tornado. You could look at an implementation like, Tornadio (https://github.com/MrJoes/tornadio) and see what methods and classes they used to hook Tornadio and Tornado together. This would give you a pretty good idea of how to integrate it with your twisted.web server.
您需要服务器端与客户端上的socket.io脚本集成。我所知道的用Python编写的服务器都使用Tornado。你可以看一下像Tornadio(https://github.com/MrJoes/tornadio)这样的实现,看看他们用来将Tornadio和Tornado挂钩的方法和类。这将使您非常了解如何将其与twisted.web服务器集成。
We've just switched away from socket.io to sockJS (which is also compatible with Tornado) and have seen large performance improvements.
我们刚刚从socket.io切换到sockJS(它也与Tornado兼容)并且已经看到了很大的性能改进。
#2
3
You could try https://github.com/DesertBus/sockjs-twisted or if you need SocketIO for a specific reason, it wouldn't be difficult to port TornadIO2 to Cyclone. You might find interesting this issue.
您可以尝试https://github.com/DesertBus/sockjs-twisted,或者如果您因特定原因需要SocketIO,将TornadIO2移植到Cyclone并不困难。你可能会发现这个问题很有趣。
#1
2
You need something server side to integrate with the socket.io script on the client side. The servers that I know that are written in Python and do this all use Tornado. You could look at an implementation like, Tornadio (https://github.com/MrJoes/tornadio) and see what methods and classes they used to hook Tornadio and Tornado together. This would give you a pretty good idea of how to integrate it with your twisted.web server.
您需要服务器端与客户端上的socket.io脚本集成。我所知道的用Python编写的服务器都使用Tornado。你可以看一下像Tornadio(https://github.com/MrJoes/tornadio)这样的实现,看看他们用来将Tornadio和Tornado挂钩的方法和类。这将使您非常了解如何将其与twisted.web服务器集成。
We've just switched away from socket.io to sockJS (which is also compatible with Tornado) and have seen large performance improvements.
我们刚刚从socket.io切换到sockJS(它也与Tornado兼容)并且已经看到了很大的性能改进。
#2
3
You could try https://github.com/DesertBus/sockjs-twisted or if you need SocketIO for a specific reason, it wouldn't be difficult to port TornadIO2 to Cyclone. You might find interesting this issue.
您可以尝试https://github.com/DesertBus/sockjs-twisted,或者如果您因特定原因需要SocketIO,将TornadIO2移植到Cyclone并不困难。你可能会发现这个问题很有趣。