Class: N::Server
- Inherits:
-
Application
- Object
- Application
- N::Server
- Defined in:
- lib/n/server.rb
Overview
Server
Base server class
Direct Known Subclasses
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
the listening address/port for this server.
-
#port ⇒ Object
readonly
the listening address/port for this server.
Attributes inherited from Application
#create_time, #daemonized, #description, #name, #pid, #pidfile, #status, #title, #version
Instance Method Summary collapse
-
#handle ⇒ Object
Override this method in your custom server.
-
#initialize(name = "Server") ⇒ Server
constructor
A new instance of Server.
-
#run ⇒ Object
The main server loop.
-
#start ⇒ Object
Start the server.
-
#stop ⇒ Object
Stop the server.
Methods inherited from Application
#daemon_pid, #daemonize, #parse_arguments, #restart
Constructor Details
#initialize(name = "Server") ⇒ Server
Returns a new instance of Server.
22 23 24 |
# File 'lib/n/server.rb', line 22 def initialize(name = "Server") super end |
Instance Attribute Details
#address ⇒ Object (readonly)
the listening address/port for this server.
20 21 22 |
# File 'lib/n/server.rb', line 20 def address @address end |
#port ⇒ Object (readonly)
the listening address/port for this server.
20 21 22 |
# File 'lib/n/server.rb', line 20 def port @port end |
Instance Method Details
#handle ⇒ Object
Override this method in your custom server. This method is very flexible, you can spawn threads, use keep alive connections, handle+close, use handler pools, anything.
56 57 |
# File 'lib/n/server.rb', line 56 def handle end |
#run ⇒ Object
The main server loop
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/n/server.rb', line 40 def run begin while :RUNNING == @status if live = IO.select(@ios, nil, nil, 2.0) end end rescue end end |
#start ⇒ Object
Start the server
28 29 30 |
# File 'lib/n/server.rb', line 28 def start super end |
#stop ⇒ Object
Stop the server
34 35 36 |
# File 'lib/n/server.rb', line 34 def stop super end |