Class: SystemBrowser::Server
- Inherits:
-
Object
- Object
- SystemBrowser::Server
- Defined in:
- lib/system_browser/server.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#initialize(port = 9696) ⇒ Server
constructor
A new instance of Server.
- #shutdown ⇒ Object
-
#start ⇒ Object
Starts the TCP server.
Constructor Details
#initialize(port = 9696) ⇒ Server
Returns a new instance of Server.
7 8 9 |
# File 'lib/system_browser/server.rb', line 7 def initialize(port = 9696) self.create_tcpserver(port) end |
Instance Attribute Details
#session ⇒ SystemBrowser::Session
5 6 7 |
# File 'lib/system_browser/server.rb', line 5 def session @session end |
Instance Method Details
#shutdown ⇒ Object
26 27 28 29 30 |
# File 'lib/system_browser/server.rb', line 26 def shutdown SLogger.debug("[server] shutting down the TCP server...") @tcpserver.close end |
#start ⇒ Object
Note:
This method blocks the thread.
Starts the TCP server.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/system_browser/server.rb', line 15 def start Socket.accept_loop(@tcpserver) do |connection| SLogger.debug("[server] accepted a new connection (#{connection})") self.session.connection = connection self.handle_connection(connection) end rescue IOError Thread.exit end |