Class: CarbonMU::TelnetConnection
- Inherits:
-
EdgeConnection
show all
- Extended by:
- Forwardable
- Defined in:
- lib/carbonmu/edge_router/telnet_connection.rb
Instance Attribute Summary collapse
#id, #name
Instance Method Summary
collapse
#handle_input, #initialize, #shutdown
Instance Attribute Details
#socket ⇒ Object
Returns the value of attribute socket.
9
10
11
|
# File 'lib/carbonmu/edge_router/telnet_connection.rb', line 9
def socket
@socket
end
|
Instance Method Details
#after_initialize(socket) ⇒ Object
11
12
13
14
|
# File 'lib/carbonmu/edge_router/telnet_connection.rb', line 11
def after_initialize(socket)
@socket = socket
async.run
end
|
#before_shutdown ⇒ Object
28
29
30
|
# File 'lib/carbonmu/edge_router/telnet_connection.rb', line 28
def before_shutdown
@socket.close unless @socket.closed?
end
|
#read ⇒ Object
32
33
34
|
# File 'lib/carbonmu/edge_router/telnet_connection.rb', line 32
def read
@socket.readpartial(4096)
end
|
#run ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/carbonmu/edge_router/telnet_connection.rb', line 16
def run
info "*** Received telnet connection #{id} from #{socket.addr[2]}"
write "Connected. Your ID is #{id}\n"
loop do
async.handle_input(read)
end
rescue EOFError, Errno::ECONNRESET
info "*** Telnet connection #{id} disconnected"
close
terminate
end
|