Class: ML_ruby::ML_client

Inherits:
Object
  • Object
show all
Defined in:
lib/ml-ruby/ml_client.rb

Constant Summary collapse

PROTOCOL_VERSION =
41
MAX_OPCODE_SENT =
59
MAX_OPCODE_RCVD =
68
TIME_OUT =
10

Instance Method Summary collapse

Constructor Details

#initialize(host = 'localhost', port = 4001, user = nil, password = nil) ⇒ ML_client

public methods



33
34
35
36
37
38
39
40
# File 'lib/ml-ruby/ml_client.rb', line 33

def initialize host='localhost', port=4001, user=nil, password=nil
  @listener= []
  @send_queue= []
  #    ML_payload_handler::Types.keys.each do |opcode|
  #      add_listener opcode, self, :log
  #    end
  connect host, port, user, password
end

Instance Method Details

#get_current_downloadsObject



42
43
44
45
46
# File 'lib/ml-ruby/ml_client.rb', line 42

def get_current_downloads
  send_payload= ML_S_get_downloading_files.new( {} )
  recv_payload= ML_R_downloading_files
  send_and_wait_for send_payload, recv_payload
end

#get_finished_downloadsObject



48
49
50
51
52
# File 'lib/ml-ruby/ml_client.rb', line 48

def get_finished_downloads
  send_payload= ML_S_get_downloaded_files.new( {} )
  recv_payload= ML_R_downloaded_files
  send_and_wait_for send_payload, recv_payload
end

#start_download(url) ⇒ Object



54
55
56
57
58
# File 'lib/ml-ruby/ml_client.rb', line 54

def start_download url
  send_opcode= ML_S_download_url.class.opcode
  sd= ML_message.new send_opcode, ML_S_download_url.new( :url=> url )
  add_to_send_queue sd
end