Skip to content

Instantly share code, notes, and snippets.

@rainux
Created January 29, 2011 09:01
Show Gist options
  • Save rainux/801693 to your computer and use it in GitHub Desktop.
Save rainux/801693 to your computer and use it in GitHub Desktop.
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