Skip to content

Instantly share code, notes, and snippets.

@francois2metz
Created May 16, 2012 07:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save francois2metz/2708313 to your computer and use it in GitHub Desktop.
Save francois2metz/2708313 to your computer and use it in GitHub Desktop.
em-eventsource with the basic example of sinatra
require "em-eventsource"
EM.run do
source = EventMachine::EventSource.new("http://localhost:4567/stream", {}, {'Accept' => 'text/event-stream'})
source.open do
puts "opened"
end
source.error do |error|
puts "error #{error}"
end
source.message do |message|
puts "new message #{message}"
end
source.start # Start listening
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment