Class: SystemBrowser::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/system_browser/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#sessionSystemBrowser::Session



5
6
7
# File 'lib/system_browser/server.rb', line 5

def session
  @session
end

Instance Method Details

#shutdownObject



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

#startObject

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