Class: EventMachine::Protocols::TcpConnectTester

Inherits:
Connection
  • Object
show all
Includes:
Deferrable
Defined in:
lib/protocols/tcptest.rb

Instance Attribute Summary

Attributes inherited from Connection

#signature

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Deferrable

#callback, #cancel_timeout, #errback, #fail, future, #set_deferred_failure, #set_deferred_status, #set_deferred_success, #succeed, #timeout

Methods inherited from Connection

#associate_callback_target, #close_connection, #close_connection_after_writing, #comm_inactivity_timeout, #comm_inactivity_timeout=, #detach, #error?, #get_outbound_data_size, #get_peer_cert, #get_peername, #get_pid, #get_sockname, #get_status, #initialize, new, #receive_data, #reconnect, #send_data, #send_datagram, #send_file_data, #set_comm_inactivity_timeout, #ssl_handshake_completed, #start_tls, #stream_file_data

Constructor Details

This class inherits a constructor from EventMachine::Connection

Class Method Details

.test(host, port) ⇒ Object



35
36
37
# File 'lib/protocols/tcptest.rb', line 35

def self.test( host, port )
  EventMachine.connect( host, port, self )
end

Instance Method Details

#connection_completedObject



43
44
45
46
47
# File 'lib/protocols/tcptest.rb', line 43

def connection_completed
  @completed = true
  set_deferred_status :succeeded, (Time.now - @start_time)
  close_connection
end

#post_initObject



39
40
41
# File 'lib/protocols/tcptest.rb', line 39

def post_init
  @start_time = Time.now
end

#unbindObject



49
50
51
# File 'lib/protocols/tcptest.rb', line 49

def unbind
  set_deferred_status :failed, (Time.now - @start_time)  unless @completed
end