Skip to content

Instantly share code, notes, and snippets.

@MichaelCPell
Created March 19, 2014 18:42
Show Gist options
  • Save MichaelCPell/9648424 to your computer and use it in GitHub Desktop.
Save MichaelCPell/9648424 to your computer and use it in GitHub Desktop.
def events
response.headers["Content-Type"] = "text/event-stream"
while(true) do
...
response.stream.write "data: #{x.to_json}\n\n"
end
rescue IOError
logger.info "Stream has closed"
ensure
response.stream.close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment