Sinatra 服务器推送? [英] Sinatra server push?

查看:45
本文介绍了Sinatra 服务器推送?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将数据从用 Sinatra 编写的服务器推送到客户端的最佳方法是什么?类似于聊天室,但没有每 2500 毫秒进行一次 Ajax 轮询.

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.

我知道 Rails 中的 Juggernaut,但对 Sinatra 很好奇.

I know of Juggernaut in Rails, but was curious about Sinatra.

推荐答案

一个小小的谷歌搜索出现 Marc-André Cournoyer 的这篇博文,其中讨论了瘦 web 服务器的异步响应功能,并包含一个指向 async-sinatra 库的链接来执行此操作.您还可以查看 orbited-ruby,这是 orbited-ruby 的 Ruby 实现.一个 href="http://orbited.org/" rel="noreferrer">Orbited Comet 服务器.这两个看起来都很新而且未经测试,因此您可能需要自己进行一些黑客攻击才能使您的应用程序正常工作.

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.

这篇关于Sinatra 服务器推送?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆