tweet_stream.rb 668 B

123456789101112131415161718192021222324252627
  1. # Copyright (C) 2012-2015 Zammad Foundation, http://zammad-foundation.org/
  2. class TweetStream < TweetBase
  3. attr_accessor :client
  4. def initialize(auth)
  5. @connection_type = 'stream'
  6. @client = Twitter::Streaming::ClientCustom.new do |config|
  7. config.consumer_key = auth[:consumer_key]
  8. config.consumer_secret = auth[:consumer_secret]
  9. config.access_token = auth[:oauth_token]
  10. config.access_token_secret = auth[:oauth_token_secret]
  11. end
  12. end
  13. def disconnect
  14. if @client && @client.custom_connection_handle
  15. @client.custom_connection_handle.close
  16. end
  17. return if !@client
  18. @client = nil
  19. end
  20. end