Class: OTerm::Server
- Inherits:
-
Object
- Object
- OTerm::Server
- Defined in:
- lib/oterm/server.rb
Instance Attribute Summary collapse
-
#acceptThread ⇒ Object
Returns the value of attribute acceptThread.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#listeners ⇒ Object
Returns the value of attribute listeners.
-
#stop ⇒ Object
Returns the value of attribute stop.
Instance Method Summary collapse
-
#initialize(executor, port = 6060, debug = false) ⇒ Server
constructor
A new instance of Server.
- #join ⇒ Object
- #remove_listener(listener) ⇒ Object
- #shutdown ⇒ Object
Constructor Details
#initialize(executor, port = 6060, debug = false) ⇒ Server
Returns a new instance of Server.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/oterm/server.rb', line 13 def initialize(executor, port=6060, debug=false) @debug = debug @stop = false @listeners = [] @acceptThread = Thread.start() do server = TCPServer.new(port) while !stop do Thread.start(server.accept()) do |con| @listeners << Listener.new(self, con, executor) end end end end |
Instance Attribute Details
#acceptThread ⇒ Object
Returns the value of attribute acceptThread.
8 9 10 |
# File 'lib/oterm/server.rb', line 8 def acceptThread @acceptThread end |
#debug ⇒ Object
Returns the value of attribute debug.
11 12 13 |
# File 'lib/oterm/server.rb', line 11 def debug @debug end |
#listeners ⇒ Object
Returns the value of attribute listeners.
10 11 12 |
# File 'lib/oterm/server.rb', line 10 def listeners @listeners end |
#stop ⇒ Object
Returns the value of attribute stop.
9 10 11 |
# File 'lib/oterm/server.rb', line 9 def stop @stop end |
Instance Method Details
#join ⇒ Object
35 36 37 |
# File 'lib/oterm/server.rb', line 35 def join() @acceptThread.join() end |
#remove_listener(listener) ⇒ Object
31 32 33 |
# File 'lib/oterm/server.rb', line 31 def remove_listener(listener) @listeners.delete(listener) end |
#shutdown ⇒ Object
27 28 29 |
# File 'lib/oterm/server.rb', line 27 def shutdown() @acceptThread.exit() end |