Class: N::Server

Inherits:
Application show all
Defined in:
lib/n/server.rb

Overview

Server

Base server class

Direct Known Subclasses

App::Server, App::Webrick

Instance Attribute Summary collapse

Attributes inherited from Application

#create_time, #daemonized, #description, #name, #pid, #pidfile, #status, #title, #version

Instance Method Summary collapse

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

#addressObject (readonly)

the listening address/port for this server.



20
21
22
# File 'lib/n/server.rb', line 20

def address
  @address
end

#portObject (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

#handleObject

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

#runObject

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

#startObject

Start the server



28
29
30
# File 'lib/n/server.rb', line 28

def start
	super
end

#stopObject

Stop the server



34
35
36
# File 'lib/n/server.rb', line 34

def stop
	super
end