Class: Sproxy::Connection
- Inherits:
-
EventMachine::Connection
- Object
- EventMachine::Connection
- Sproxy::Connection
- Defined in:
- lib/sproxy/connection.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Connection
constructor
A new instance of Connection.
- #receive_data(data) ⇒ Object
- #unbind ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Connection
Returns a new instance of Connection.
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/sproxy/connection.rb', line 3 def initialize( = {}) if [:related_connection] @related_connection = [:related_connection] else addr = [:target_addr] port = [:target_port] opts = {related_connection: self} @related_connection = EventMachine.connect(addr, port, Connection, opts) end super end |
Instance Method Details
#receive_data(data) ⇒ Object
16 17 18 |
# File 'lib/sproxy/connection.rb', line 16 def receive_data(data) @related_connection.send_data(data) end |
#unbind ⇒ Object
20 21 22 |
# File 'lib/sproxy/connection.rb', line 20 def unbind @related_connection.close_connection end |