Class: PDTP::Server::TransferManager

Inherits:
Object
  • Object
show all
Defined in:
lib/pdtp/server/transfer_manager.rb

Overview

Decision-making logic for initiating peer-to-peer transfers

Instance Method Summary collapse

Constructor Details

#initialize(connections, file_service) ⇒ TransferManager

Returns a new instance of TransferManager.



29
30
31
32
# File 'lib/pdtp/server/transfer_manager.rb', line 29

def initialize(connections, file_service)
  @connections, @file_service = connections, file_service
  @updated_clients = []
end

Instance Method Details

#process_client(client) ⇒ Object

Add client to list of ones needing updates



35
36
37
# File 'lib/pdtp/server/transfer_manager.rb', line 35

def process_client(client)
  @updated_clients << client
end

#spawn_all_transfersObject

Creates new transfers for all clients that have been updated



40
41
42
43
# File 'lib/pdtp/server/transfer_manager.rb', line 40

def spawn_all_transfers
  @updated_clients.each { |client| spawn_transfers_for_client(client) }
  @updated_clients.clear
end