Created
January 29, 2011 09:01
-
-
Save rainux/801693 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 'rubygems' | |
require 'eventmachine' | |
require 'twitter/json_stream' | |
module Twitter | |
class JSONStream | |
def unbind | |
# The override just added a call to puts | |
puts '==unbind' | |
receive_line(@buffer.flush) unless @buffer.empty? | |
schedule_reconnect unless @gracefully_closed | |
end | |
end | |
end | |
EM.run do | |
stream = Twitter::JSONStream.connect( | |
:filters => %w(ruby), | |
:ssl => true, | |
:auth => 'YOUR_TWITTER_USERNAME:YOUR_TWITTER_PASSWORD' | |
) | |
stream.each_item do |item| | |
puts 'item received' | |
end | |
puts 'Connected' | |
EM.add_timer(5) { | |
puts 'Reconnecting' | |
stream.immediate_reconnect | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment