Class: ReverseTunnel::Client::TunnelConnection
- Inherits:
-
EventMachine::Connection
- Object
- EventMachine::Connection
- ReverseTunnel::Client::TunnelConnection
- Defined in:
- lib/reverse-tunnel/client.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#hearbeat ⇒ Object
readonly
Returns the value of attribute hearbeat.
-
#tunnel ⇒ Object
Returns the value of attribute tunnel.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(tunnel) ⇒ TunnelConnection
constructor
A new instance of TunnelConnection.
- #message_unpacker ⇒ Object
- #post_init ⇒ Object
- #receive_data(data) ⇒ Object
- #unbind ⇒ Object
Constructor Details
#initialize(tunnel) ⇒ TunnelConnection
Returns a new instance of TunnelConnection.
186 187 188 |
# File 'lib/reverse-tunnel/client.rb', line 186 def initialize(tunnel) @tunnel = tunnel end |
Instance Attribute Details
#created_at ⇒ Object
Returns the value of attribute created_at.
182 183 184 |
# File 'lib/reverse-tunnel/client.rb', line 182 def created_at @created_at end |
#hearbeat ⇒ Object (readonly)
Returns the value of attribute hearbeat.
184 185 186 |
# File 'lib/reverse-tunnel/client.rb', line 184 def hearbeat @hearbeat end |
#tunnel ⇒ Object
Returns the value of attribute tunnel.
182 183 184 |
# File 'lib/reverse-tunnel/client.rb', line 182 def tunnel @tunnel end |
Instance Method Details
#as_json ⇒ Object
202 203 204 |
# File 'lib/reverse-tunnel/client.rb', line 202 def as_json { :created_at => created_at } end |
#message_unpacker ⇒ Object
198 199 200 |
# File 'lib/reverse-tunnel/client.rb', line 198 def @message_unpacker ||= Message::Unpacker.new end |
#post_init ⇒ Object
190 191 192 193 194 195 196 |
# File 'lib/reverse-tunnel/client.rb', line 190 def post_init ReverseTunnel.logger.debug { "New tunnel connection" } self.created_at = Time.now tunnel.connection = self tunnel.open end |
#receive_data(data) ⇒ Object
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/reverse-tunnel/client.rb', line 206 def receive_data(data) ReverseTunnel.logger.debug { "Received data '#{data.unpack('H*').join}'" } .feed data .each do || ReverseTunnel.logger.debug { "Received message in tunnel #{.inspect}" } if .data? tunnel.receive_data .session_id, .data elsif .open_session? tunnel.open_session .session_id elsif .ping? tunnel.ping_received end end end |
#unbind ⇒ Object
223 224 225 226 |
# File 'lib/reverse-tunnel/client.rb', line 223 def unbind ReverseTunnel.logger.debug { "Close tunnel connection" } tunnel.connection = nil end |