服务器发送的事件方法未由 Firefox 处理
Server-Sent Event method not handled by Firefox
我正在使用ActionController构建一个rails应用程序::Live and and Custom SSE库,我的服务器是彪马,rails 版本是 4,这是我在控制器中的代码:
include ActionController::Live
def index
response.headers['Content-Type'] = 'text/event-stream'
ss = Reloader::SSE.new(response.stream)
100.times {
ss.write({ :message => "just checking"}, :event => 'refresh')
sleep 10
}
ensure
ss.close
end
这是我的图书馆 sse.rb 文件
class SSE
def initialize io
@io = io
end
def write object, options = {}
options.each do |k,v|
@io.write "#{k}: #{v}'n"
end
@io.write "data: #{JSON.dump(object)}'n'n"
end
def close
@io.close
end
end
这是我的应用程序.js文件来处理SSE
$(document).ready(function() {
setTimeout(function() {
var source = new EventSource('/');
source.addEventListener('refresh', function(e) {
window.location.reload();
});
}, 1);
});
我正在按照这个网站的教程 http://tenderlovemaking.com/2012/07/30/is-it-live.html每当我加载我的 Firefox 页面时,它都不会处理流,而是显示将流下载为文本文件的选项。我不知道为什么会发生这种情况。
我对SSE的理解在这里是错误的,SSE和我正在工作的页面/控制器,我将它们视为一个,我试图在Firefox或chrome中查看SSE的控制器。我对上交所的理解很差。SSE 控制器和我要触发事件的页面是完全不同的。我在本教程结束时得到了这个答案
http://tenderlovemaking.com/2012/07/30/is-it-live.html
希望你们也得到它。
相关文章:
- Firefox赢得了't在keydown处理程序中设置input.value..但它在调试时起作用
- 服务器发送的事件方法未由 Firefox 处理
- 使用 Javascript 运行批处理文件 - Firefox
- Firefox 不会对 SVG 大小更改进行动画处理
- 如何处理 Firefox 扩展中修改的链接点击事件
- 更改“input”事件处理程序中的输入值可防止在Chrome和IE中触发“更改”事件(但在Firefox中则不然)
- 将大约 300 张画布图像保存在一个数组中并发送一次进行处理,在 chrome 中崩溃,但在 Firefox 中工作正常
- 防止鼠标滚轮事件被 Firefox 中的 Flash 处理
- 通过 AngularJS 处理 Firefox 中的数字输入
- Chrome不处理像Firefox、Safari这样的分块响应
- Firefox可以'我无法处理jQuery
- 如何处理用户在Firefox和Chrome中关闭“物理位置”提示
- Chrome和Firefox处理JavaScript/HTML的方式不同
- 为什么Chrome和Firefox处理Javascript链接的方式不同
- 协调Firefox斜杠处理和密钥代码
- Firefox没有处理keyCode's.它在调试器中将变量显示为矩阵
- 如何处理'无效赋值left hand '错误:firefox或chrome
- 让firefox扩展识别tel:标签并处理它
- javascript事件.在FireFox 3.6.25中,keyCode不能处理keydown、keypress或ke
- Firefox处理窗口吗?onpopstate与Chrome和Safari不同