Ruby on rails 在本例中,为什么服务器发送事件中存在循环?
例()Ruby on rails 在本例中,为什么服务器发送事件中存在循环?,ruby-on-rails,server-sent-events,Ruby On Rails,Server Sent Events,例() class AuthyControllertime.now}) 睡眠1 结束 救援客户断开连接 确保 sse.close 结束 结束 结束 我在本地服务器上测试了它,得到了连续的时间流。。。还是我做错了什么 class AuthyController < ApplicationController def one_touch_status_live response.headers['Content-Type'] = 'text/event-stream' s
class AuthyControllertime.now})
睡眠1
结束
救援客户断开连接
确保
sse.close
结束
结束
结束
我在本地服务器上测试了它,得到了连续的时间流。。。还是我做错了什么
class AuthyController < ApplicationController
def one_touch_status_live
response.headers['Content-Type'] = 'text/event-stream'
sse = SSE.new(response.stream, event: 'time')
begin
loop do
sse.write({ :time => Time.now })
sleep 1
end
rescue ClientDisconnected
ensure
sse.close
end
end
end