Class: ReverseTunnel::Client::LocalConnection
- Inherits:
-
EventMachine::Connection
- Object
- EventMachine::Connection
- ReverseTunnel::Client::LocalConnection
- Defined in:
- lib/reverse-tunnel/client.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#received_size ⇒ Object
readonly
Returns the value of attribute received_size.
-
#send_size ⇒ Object
readonly
Returns the value of attribute send_size.
-
#session_id ⇒ Object
Returns the value of attribute session_id.
-
#tunnel ⇒ Object
Returns the value of attribute tunnel.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(tunnel, session_id) ⇒ LocalConnection
constructor
A new instance of LocalConnection.
- #post_init ⇒ Object
- #receive_data(data) ⇒ Object
- #send_data(data) ⇒ Object
- #unbind ⇒ Object
Constructor Details
#initialize(tunnel, session_id) ⇒ LocalConnection
Returns a new instance of LocalConnection.
235 236 237 238 |
# File 'lib/reverse-tunnel/client.rb', line 235 def initialize(tunnel, session_id) @tunnel, @session_id = tunnel, session_id @received_size = @send_size = 0 end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
233 234 235 |
# File 'lib/reverse-tunnel/client.rb', line 233 def created_at @created_at end |
#received_size ⇒ Object (readonly)
Returns the value of attribute received_size.
233 234 235 |
# File 'lib/reverse-tunnel/client.rb', line 233 def received_size @received_size end |
#send_size ⇒ Object (readonly)
Returns the value of attribute send_size.
233 234 235 |
# File 'lib/reverse-tunnel/client.rb', line 233 def send_size @send_size end |
#session_id ⇒ Object
Returns the value of attribute session_id.
231 232 233 |
# File 'lib/reverse-tunnel/client.rb', line 231 def session_id @session_id end |
#tunnel ⇒ Object
Returns the value of attribute tunnel.
231 232 233 |
# File 'lib/reverse-tunnel/client.rb', line 231 def tunnel @tunnel end |
Instance Method Details
#as_json ⇒ Object
263 264 265 |
# File 'lib/reverse-tunnel/client.rb', line 263 def as_json { :session_id => session_id, :created_at => created_at, :received_size => received_size, :send_size => send_size } end |
#post_init ⇒ Object
240 241 242 243 244 |
# File 'lib/reverse-tunnel/client.rb', line 240 def post_init ReverseTunnel.logger.debug { "New local connection" } @created_at = Time.now tunnel.local_connections << self end |
#receive_data(data) ⇒ Object
246 247 248 249 250 |
# File 'lib/reverse-tunnel/client.rb', line 246 def receive_data(data) ReverseTunnel.logger.debug { "Received data in local connection #{session_id}" } @received_size += data.size tunnel.send_data session_id, data end |
#send_data(data) ⇒ Object
257 258 259 260 261 |
# File 'lib/reverse-tunnel/client.rb', line 257 def send_data(data) ReverseTunnel.logger.debug { "Send data '#{data.unpack('H*').join}'" } @send_size += data.size super end |
#unbind ⇒ Object
252 253 254 255 |
# File 'lib/reverse-tunnel/client.rb', line 252 def unbind ReverseTunnel.logger.debug { "Close local connection #{session_id}" } tunnel.local_connections.delete self end |