Class: ReverseTunnel::Server::LocalConnection

Inherits:
EventMachine::Connection
  • Object
show all
Defined in:
lib/reverse-tunnel/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tunnel) ⇒ LocalConnection

Returns a new instance of LocalConnection.



267
268
269
# File 'lib/reverse-tunnel/server.rb', line 267

def initialize(tunnel)
  @tunnel = tunnel
end

Instance Attribute Details

#tunnelObject

Returns the value of attribute tunnel.



265
266
267
# File 'lib/reverse-tunnel/server.rb', line 265

def tunnel
  @tunnel
end

Instance Method Details

#post_initObject



271
272
273
274
275
# File 'lib/reverse-tunnel/server.rb', line 271

def post_init
  ReverseTunnel.logger.debug { "New local connection" }
  tunnel.local_connections << self
  tunnel.open_session(session_id)
end

#receive_data(data) ⇒ Object



277
278
279
280
# File 'lib/reverse-tunnel/server.rb', line 277

def receive_data(data)
  ReverseTunnel.logger.debug { "Received data in local #{session_id}" }
  tunnel.send_data session_id, data
end

#session_idObject



282
283
284
# File 'lib/reverse-tunnel/server.rb', line 282

def session_id
  @session_id ||= tunnel.next_session_id
end

#unbindObject



286
287
288
289
# File 'lib/reverse-tunnel/server.rb', line 286

def unbind
  ReverseTunnel.logger.debug { "Close local connection" }
  tunnel.local_connections.delete self
end