Sinatra 服务器推送?
将数据从用 Sinatra 编写的服务器推送到客户端的最佳方法是什么? 与聊天室类似,但没有 Ajax 每 2500 毫秒轮询一次。
我知道 Rails 中的 Juggernaut,但对 Sinatra 很好奇。
What is the best way to push data from a server written in Sinatra to a client? Think similarly to a chat room, but without Ajax polling every 2500ms.
I know of Juggernaut in Rails, but was curious about Sinatra.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
谷歌搜索了一下,发现了 Marc-André 的这篇博文Cournoyer,它讨论了 Thin Web 服务器的异步响应功能,并包含一个指向 async-sinatra 库的链接来执行此操作。 您还可以查看 orbited-ruby,它是 < a href="http://orbited.org/" rel="noreferrer">轨道彗星服务器。 这两者似乎都是相当新的且未经测试的,因此您可能需要自己进行一些修改才能使您的应用程序正常工作。
A little googling turned up this blog post by Marc-André Cournoyer, which discusses the asynchronous response feature of the Thin web server and includes a link to an async-sinatra library to do just this. You could also take a look at orbited-ruby, a Ruby implementation of the Orbited Comet server. Both of these appear to be pretty new and untested, so you might have to do a little hacking yourselves to get things working correctly for your application.