Sha256: f132585c97713c0a3e5e422cdb8f88ef17edfb3f43fca1e722fa111462cdc2eb

Contents?: true

Size: 1015 Bytes

Versions: 20

Compression:

Stored size: 1015 Bytes

Contents

require 'rubygems'
lib_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)

require 'twitter/json_stream'

EventMachine::run {
  stream = Twitter::JSONStream.connect(
    :path    => '/1/statuses/filter.json',
    :auth    => 'LOGIN:PASSWORD',
    :method  => 'POST',
    :content => 'track=basketball,football,baseball,footy,soccer'
  )
    
  stream.each_item do |item|
    $stdout.print "item: #{item}\n"
    $stdout.flush
  end
  
  stream.on_error do |message|
    $stdout.print "error: #{message}\n"
    $stdout.flush
  end
  
  stream.on_reconnect do |timeout, retries|
    $stdout.print "reconnecting in: #{timeout} seconds\n"
    $stdout.flush
  end
  
  stream.on_max_reconnects do |timeout, retries|
    $stdout.print "Failed after #{retries} failed reconnects\n"
    $stdout.flush
  end
  
  trap('TERM') {  
    stream.stop
    EventMachine.stop if EventMachine.reactor_running? 
  }
}
puts "The event loop has ended"

Version data entries

20 entries across 20 versions & 4 rubygems

Version Path
cantino-twitter-stream-0.1.15 examples/reader.rb
lukemelia-twitter-stream-0.1.16 examples/reader.rb
twitter-stream-0.1.16 examples/reader.rb
lukemelia-twitter-stream-0.1.15 examples/reader.rb
twitter-stream-0.1.15 examples/reader.rb
twitter-stream-0.1.14 examples/reader.rb
twitter-stream-0.1.13 examples/reader.rb
twitter-stream-0.1.12 examples/reader.rb
twitter-stream-0.1.11 examples/reader.rb
xh5-twitter-stream-0.1.0 examples/reader.rb
twitter-stream-0.1.10 examples/reader.rb
twitter-stream-0.1.9 examples/reader.rb
twitter-stream-0.1.8 examples/reader.rb
twitter-stream-0.1.7 examples/reader.rb
twitter-stream-0.1.6 examples/reader.rb
twitter-stream-0.1.4 examples/reader.rb
twitter-stream-0.1.3 examples/reader.rb
twitter-stream-0.1.2 examples/reader.rb
twitter-stream-0.1.1 examples/reader.rb
twitter-stream-0.1.0 examples/reader.rb