Created
May 16, 2012 07:25
-
-
Save francois2metz/2708313 to your computer and use it in GitHub Desktop.
em-eventsource with the basic example of sinatra
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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