Class: Tunnels::HttpClient
- Inherits:
-
EventMachine::Connection
- Object
- EventMachine::Connection
- Tunnels::HttpClient
- Defined in:
- lib/tunnels.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#proxy ⇒ Object
readonly
Returns the value of attribute proxy.
-
#to_host ⇒ Object
readonly
Returns the value of attribute to_host.
-
#to_port ⇒ Object
readonly
Returns the value of attribute to_port.
Instance Method Summary collapse
- #connection_completed ⇒ Object
-
#initialize(proxy, from_host, from_port, to_host, to_port) ⇒ HttpClient
constructor
A new instance of HttpClient.
- #receive_data(data) ⇒ Object
- #send(data) ⇒ Object
- #unbind ⇒ Object
Constructor Details
#initialize(proxy, from_host, from_port, to_host, to_port) ⇒ HttpClient
Returns a new instance of HttpClient.
98 99 100 101 102 |
# File 'lib/tunnels.rb', line 98 def initialize(proxy, from_host, from_port, to_host, to_port) @proxy = proxy @connected = EventMachine::DefaultDeferrable.new @from_host, @from_port, @to_host, @to_port = from_host, from_port, to_host, to_port end |
Instance Attribute Details
#proxy ⇒ Object (readonly)
Returns the value of attribute proxy.
96 97 98 |
# File 'lib/tunnels.rb', line 96 def proxy @proxy end |
#to_host ⇒ Object (readonly)
Returns the value of attribute to_host.
96 97 98 |
# File 'lib/tunnels.rb', line 96 def to_host @to_host end |
#to_port ⇒ Object (readonly)
Returns the value of attribute to_port.
96 97 98 |
# File 'lib/tunnels.rb', line 96 def to_port @to_port end |
Instance Method Details
#connection_completed ⇒ Object
104 105 106 |
# File 'lib/tunnels.rb', line 104 def connection_completed @connected.succeed end |
#receive_data(data) ⇒ Object
108 109 110 |
# File 'lib/tunnels.rb', line 108 def receive_data(data) proxy.relay_from_client(data) end |
#send(data) ⇒ Object
112 113 114 |
# File 'lib/tunnels.rb', line 112 def send(data) @connected.callback { send_data data } end |
#unbind ⇒ Object
116 117 118 |
# File 'lib/tunnels.rb', line 116 def unbind proxy.unbind_client @from_host, @from_port end |