Class: Tunnels::HttpClient

Inherits:
EventMachine::Connection
  • Object
show all
Defined in:
lib/tunnels.rb

Direct Known Subclasses

HttpsClient

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(proxy, from_host, from_port, to_host, to_port) ⇒ HttpClient

Returns a new instance of HttpClient.



95
96
97
98
99
# File 'lib/tunnels.rb', line 95

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

#proxyObject (readonly)

Returns the value of attribute proxy.



93
94
95
# File 'lib/tunnels.rb', line 93

def proxy
  @proxy
end

#to_hostObject (readonly)

Returns the value of attribute to_host.



93
94
95
# File 'lib/tunnels.rb', line 93

def to_host
  @to_host
end

#to_portObject (readonly)

Returns the value of attribute to_port.



93
94
95
# File 'lib/tunnels.rb', line 93

def to_port
  @to_port
end

Instance Method Details

#connection_completedObject



101
102
103
# File 'lib/tunnels.rb', line 101

def connection_completed
  @connected.succeed
end

#receive_data(data) ⇒ Object



105
106
107
# File 'lib/tunnels.rb', line 105

def receive_data(data)
  proxy.relay_from_client(data)
end

#send(data) ⇒ Object



109
110
111
# File 'lib/tunnels.rb', line 109

def send(data)
  @connected.callback { send_data data }
end

#unbindObject



113
114
115
# File 'lib/tunnels.rb', line 113

def unbind
  proxy.unbind_client @from_host, @from_port
end