Class: DRb::DRbSSHServer
- Inherits:
-
Object
- Object
- DRb::DRbSSHServer
- Defined in:
- lib/drbssh.rb
Overview
Common DRb protocol server for DRbSSH. Waits on incoming clients on a thread-safe ‘Queue`, and spawns a new connection handler for each.
Instance Attribute Summary collapse
-
#client_queue ⇒ Object
readonly
Returns the value of attribute client_queue.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#accept ⇒ Object
Wait for clients to register themselves on the client_queue.
-
#close ⇒ Object
Close server by closing all clients.
-
#closed? ⇒ Boolean
Server is closed if
close
has been called earlier. -
#initialize(uri, config) ⇒ DRbSSHServer
constructor
Create new server.
Constructor Details
#initialize(uri, config) ⇒ DRbSSHServer
Create new server.
173 174 175 176 177 178 |
# File 'lib/drbssh.rb', line 173 def initialize(uri, config) @uri = uri @config = config @client_queue = Queue.new @clients = [] end |
Instance Attribute Details
#client_queue ⇒ Object (readonly)
Returns the value of attribute client_queue.
170 171 172 |
# File 'lib/drbssh.rb', line 170 def client_queue @client_queue end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
169 170 171 |
# File 'lib/drbssh.rb', line 169 def uri @uri end |
Instance Method Details
#accept ⇒ Object
Wait for clients to register themselves on the client_queue.
181 182 183 184 185 |
# File 'lib/drbssh.rb', line 181 def accept client = @client_queue.pop @clients << DRbSSHServerConn.new(uri, @config, client) @clients.last end |
#close ⇒ Object
Close server by closing all clients.
188 189 190 191 |
# File 'lib/drbssh.rb', line 188 def close @clients.map(&:close) @clients = nil end |
#closed? ⇒ Boolean
Server is closed if close
has been called earlier.
194 195 196 |
# File 'lib/drbssh.rb', line 194 def closed? @clients.nil? end |