Class: Baykit::BayServer::Agent::AcceptHandler
- Inherits:
-
Object
- Object
- Baykit::BayServer::Agent::AcceptHandler
- Includes:
- Baykit::BayServer::Agent, Util
- Defined in:
- lib/baykit/bayserver/agent/accept_handler.rb
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#ch_count ⇒ Object
readonly
Returns the value of attribute ch_count.
-
#is_shutdown ⇒ Object
readonly
Returns the value of attribute is_shutdown.
-
#port_map ⇒ Object
readonly
Returns the value of attribute port_map.
Instance Method Summary collapse
- #close_all ⇒ Object
-
#initialize(agent, port_map) ⇒ AcceptHandler
constructor
A new instance of AcceptHandler.
- #on_acceptable(server_skt) ⇒ Object
- #on_busy ⇒ Object
- #on_closed ⇒ Object
- #on_free ⇒ Object
- #server_socket?(skt) ⇒ Boolean
- #shutdown ⇒ Object
Constructor Details
#initialize(agent, port_map) ⇒ AcceptHandler
Returns a new instance of AcceptHandler.
18 19 20 21 22 23 |
# File 'lib/baykit/bayserver/agent/accept_handler.rb', line 18 def initialize(agent, port_map) @agent = agent @port_map = port_map @ch_count = 0 @is_shutdown = false end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
12 13 14 |
# File 'lib/baykit/bayserver/agent/accept_handler.rb', line 12 def agent @agent end |
#ch_count ⇒ Object (readonly)
Returns the value of attribute ch_count.
16 17 18 |
# File 'lib/baykit/bayserver/agent/accept_handler.rb', line 16 def ch_count @ch_count end |
#is_shutdown ⇒ Object (readonly)
Returns the value of attribute is_shutdown.
15 16 17 |
# File 'lib/baykit/bayserver/agent/accept_handler.rb', line 15 def is_shutdown @is_shutdown end |
#port_map ⇒ Object (readonly)
Returns the value of attribute port_map.
13 14 15 |
# File 'lib/baykit/bayserver/agent/accept_handler.rb', line 13 def port_map @port_map end |
Instance Method Details
#close_all ⇒ Object
54 55 56 57 58 59 |
# File 'lib/baykit/bayserver/agent/accept_handler.rb', line 54 def close_all() @port_map.keys.each do |skt| BayLog.debug("%s Close server Socket: %s", @agent, skt) skt.close() end end |
#on_acceptable(server_skt) ⇒ Object
25 26 |
# File 'lib/baykit/bayserver/agent/accept_handler.rb', line 25 def on_acceptable(server_skt) end |
#on_busy ⇒ Object
32 33 34 35 36 37 |
# File 'lib/baykit/bayserver/agent/accept_handler.rb', line 32 def on_busy() BayLog.debug("%s AcceptHandler:onBusy", @agent) @port_map.keys().each do |ch| @agent.selector.unregister(ch) end end |
#on_closed ⇒ Object
28 29 30 |
# File 'lib/baykit/bayserver/agent/accept_handler.rb', line 28 def on_closed() @ch_count -= 1 end |
#on_free ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/baykit/bayserver/agent/accept_handler.rb', line 39 def on_free() BayLog.debug("%s AcceptHandler:onFree isShutdown=%s", @agent, @is_shutdown) if @is_shutdown return end @port_map.keys().each do |ch| @agent.selector.register(ch, Selector::OP_READ) end end |
#server_socket?(skt) ⇒ Boolean
50 51 52 |
# File 'lib/baykit/bayserver/agent/accept_handler.rb', line 50 def server_socket?(skt) return @port_map.key?(skt) end |
#shutdown ⇒ Object
61 62 63 64 65 |
# File 'lib/baykit/bayserver/agent/accept_handler.rb', line 61 def shutdown() @is_shutdown = true on_busy() @agent.wakeup() end |