Class: DRb::DRbSSHServer

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_queueObject (readonly)

Returns the value of attribute client_queue.



170
171
172
# File 'lib/drbssh.rb', line 170

def client_queue
  @client_queue
end

#uriObject (readonly)

Returns the value of attribute uri.



169
170
171
# File 'lib/drbssh.rb', line 169

def uri
  @uri
end

Instance Method Details

#acceptObject

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

#closeObject

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.

Returns:

  • (Boolean)


194
195
196
# File 'lib/drbssh.rb', line 194

def closed?
  @clients.nil?
end