### Home Classes Methods

### In Files

- lib/plugins/user_stream.rb

### Parent

Object

### Methods

- ::repack_error
- #process
- #run

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- Termtter
- Termtter::API
- Termtter::ActiveRubytter
- Termtter::Client
- Termtter::Client::UserSearchEvent
- Termtter::Command
- Termtter::CommandLine
- Termtter::Config
- Termtter::ConfigSetup
- Termtter::Crypt
- Termtter::Event
- Termtter::HTTPpool
- Termtter::Hook
- Termtter::HookCanceled
- Termtter::Hookable
- Termtter::JSONError
- Termtter::MemoryCache
- Termtter::MemoryCache::MemCacheMock
- Termtter::OptParser
- Termtter::Plugin
- Termtter::Plugin::Screen
- Termtter::Plugins
- Termtter::Plugins::Haml
- Termtter::RubytterProxy
- Termtter::RubytterProxy::FrequentAccessError
- Termtter::RubytterProxy::LimitManager
- Termtter::Status
- Termtter::Storage
- Termtter::Storage::Status
- Termtter::Task
- Termtter::TaskManager
- Termtter::UserStreamReceiver
- OAuth
- OAuth::AccessToken
- Array
- Growl
- IRB
- Object
- Readline
- Status
- String
- Symbol
- TermColor
- User

No matching classes.

# Termtter::UserStreamReceiver

### Constants

ENDPOINT

### Public Class Methods

repack_error(error, chunk) click to toggle source

    # File lib/plugins/user_stream.rb, line 15
    def self.repack_error(error, chunk)
      new_error = error.class.new("#{error.message} (#{JSON.parse(chunk).inspect})")
      error.instance_variables.each{ |v|
        new_error.instance_variable_set(v, error.instance_variable_get(v))
      }
      new_error
    rescue
      error
    end

### Public Instance Methods

run(&block) click to toggle source

    # File lib/plugins/user_stream.rb, line 4
    def run(&block)
      loop {
        begin
          self.process &block
        rescue => error
          Termtter::Client.handle_error error
          sleep 10
        end
      }
    end

### Protected Instance Methods

process(&block) click to toggle source

    # File lib/plugins/user_stream.rb, line 28
    def process(&block)
      Termtter::Client.logger.info("connecting to UserStream")
      https = Net::HTTP.new(ENDPOINT.host, ENDPOINT.port)
      https.use_ssl = true
      https.verify_mode = OpenSSL::SSL::VERIFY_NONE

      https.start{ |https|
        request = Net::HTTP::Get.new(ENDPOINT.request_uri)
        request.oauth!(https, Termtter::API.twitter.access_token.consumer, Termtter::API.twitter.access_token)
        https.request(request){ |response|
          raise StandardError, response.code.to_i unless response.code.to_i == 200
          raise StandardError, 'Response is not chuncked' unless response.chunked?
          Termtter::Client.logger.info("connected to UserStream")
          response.read_body{ |chunk|
            Termtter::Client.logger.debug("received: #{chunk}")
            yield chunk
          }
        }
      }
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.