Class: RProxy::CallbackConnection

Inherits:
EM::Connection
  • Object
show all
Defined in:
lib/r_proxy/callback_connection.rb

Instance Method Summary collapse

Constructor Details

#initialize(uri, user, pass, value, tls) ⇒ CallbackConnection

Returns a new instance of CallbackConnection.



3
4
5
6
7
8
9
10
# File 'lib/r_proxy/callback_connection.rb', line 3

def initialize(uri, user, pass, value, tls)
  @uri = uri
  @path = uri.path.empty? ? '/' : uri.path
  @http_request = RProxy::HttpPostTemplate.
    new(@uri, @path).create(user, pass, value)
  @response = ''
  @need_tls = tls
end

Instance Method Details

#assign_logger(logger) ⇒ Object



12
13
14
# File 'lib/r_proxy/callback_connection.rb', line 12

def assign_logger(logger)
  @logger = logger
end

#connection_completedObject



25
26
27
# File 'lib/r_proxy/callback_connection.rb', line 25

def connection_completed
  send_data(@http_request) if !@need_tls
end

#post_initObject



16
17
18
19
# File 'lib/r_proxy/callback_connection.rb', line 16

def post_init
  start_tls if @need_tls
  set_comm_inactivity_timeout(20)
end

#receive_data(data) ⇒ Object



29
30
31
32
# File 'lib/r_proxy/callback_connection.rb', line 29

def receive_data(data)
  @response = data.split("\r\n")[0]
  close_connection
end

#ssl_handshake_completedObject



21
22
23
# File 'lib/r_proxy/callback_connection.rb', line 21

def ssl_handshake_completed
  send_data(@http_request)
end

#unbindObject



34
35
36
# File 'lib/r_proxy/callback_connection.rb', line 34

def unbind
  @logger.info("#{@uri.host}#{@path} response status: #{@response}") if @logger
end