Parent

Methods

Class/Module Index [+]

Quicksearch

Twitter::Streaming::Connection

Attributes

ssl_socket_class[R]
tcp_socket_class[R]

Public Class Methods

new(opts = {}) click to toggle source
# File lib/twitter/streaming/connection.rb, line 8
def initialize(opts = {})
  @tcp_socket_class = opts.fetch(:tcp_socket_class) { TCPSocket }
  @ssl_socket_class = opts.fetch(:ssl_socket_class) { OpenSSL::SSL::SSLSocket }
end

Public Instance Methods

stream(request, response) click to toggle source
# File lib/twitter/streaming/connection.rb, line 14
def stream(request, response)
  client_context = OpenSSL::SSL::SSLContext.new
  client         = @tcp_socket_class.new(Resolv.getaddress(request.uri.host), request.uri.port)
  ssl_client     = @ssl_socket_class.new(client, client_context)

  ssl_client.connect
  request.stream(ssl_client)
  while body = ssl_client.readpartial(1024) # rubocop:disable AssignmentInCondition, WhileUntilModifier
    response << body
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.