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.



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

#proxyObject (readonly)

Returns the value of attribute proxy.



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

def proxy
  @proxy
end

#to_hostObject (readonly)

Returns the value of attribute to_host.



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

def to_host
  @to_host
end

#to_portObject (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_completedObject



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

#unbindObject



116
117
118
# File 'lib/tunnels.rb', line 116

def unbind
  proxy.unbind_client @from_host, @from_port
end