Class: CarbonMU::TelnetReceptor

Inherits:
Object
  • Object
show all
Includes:
Celluloid::IO, Celluloid::Logger
Defined in:
lib/carbonmu/edge_router/telnet_receptor.rb

Instance Method Summary collapse

Constructor Details

#initialize(host, port) ⇒ TelnetReceptor

Returns a new instance of TelnetReceptor.



12
13
14
15
16
# File 'lib/carbonmu/edge_router/telnet_receptor.rb', line 12

def initialize(host, port)
  info "*** Starting Telnet receptor on #{host} #{port}."
  @server = Celluloid::IO::TCPServer.new(host, port)
  async.run
end

Instance Method Details

#handle_connection(socket) ⇒ Object



26
27
28
29
# File 'lib/carbonmu/edge_router/telnet_receptor.rb', line 26

def handle_connection(socket)
  tc = TelnetConnection.new(socket)
  Actor[:edge_router].add_connection(tc)
end

#runObject



22
23
24
# File 'lib/carbonmu/edge_router/telnet_receptor.rb', line 22

def run
  loop { async.handle_connection @server.accept }
end

#shutdownObject



18
19
20
# File 'lib/carbonmu/edge_router/telnet_receptor.rb', line 18

def shutdown
  @server.close if @server
end