Class: DebugServer::Server
- Inherits:
-
Object
- Object
- DebugServer::Server
- Defined in:
- lib/debugserver/server.rb
Instance Attribute Summary collapse
-
#sessions ⇒ Object
readonly
Returns the value of attribute sessions.
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Instance Method Summary collapse
-
#close_session(s) ⇒ Object
close existing session on client disconnect.
-
#initialize ⇒ Server
constructor
A new instance of Server.
-
#start ⇒ Object
start server execution.
-
#stop ⇒ Object
stop server executions.
Constructor Details
#initialize ⇒ Server
Returns a new instance of Server.
23 24 25 26 |
# File 'lib/debugserver/server.rb', line 23 def initialize @socket = nil @sessions = [] end |
Instance Attribute Details
#sessions ⇒ Object (readonly)
Returns the value of attribute sessions.
10 11 12 |
# File 'lib/debugserver/server.rb', line 10 def sessions @sessions end |
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
9 10 11 |
# File 'lib/debugserver/server.rb', line 9 def socket @socket end |
Instance Method Details
#close_session(s) ⇒ Object
close existing session on client disconnect
29 30 31 |
# File 'lib/debugserver/server.rb', line 29 def close_session(s) @sessions.delete(s) end |
#start ⇒ Object
start server execution
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/debugserver/server.rb', line 34 def start config = DebugServer.config system('clear') puts "Starting debug server on #{config[:host]}:#{config[:port]}..." begin EventMachine::run do EventMachine.epoll @socket = EventMachine::start_server(config[:host], config[:port], Session) do |s| init_session(s) end end rescue Interrupt stop rescue RuntimeError => err puts "Runtime error: #{err.}" stop end end |
#stop ⇒ Object
stop server executions
56 57 58 59 |
# File 'lib/debugserver/server.rb', line 56 def stop puts "Exiting..." exit(0) end |