Changes between Version 8 and Version 9 of archive/Development/UiClient


Ignore:
Timestamp:
02/23/2008 09:45:59 AM (16 years ago)
Author:
mvoncken
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • archive/Development/UiClient

    v8 v9  
    77 
    88It is used by all deluge user interfaces. 
    9  
    10 == aclient == 
    11 The asynchronous api. 
    12  
    13 Used by rich user interfaces like gtk, or for performance critical batch-calls in webui. 
    14  
    15 {{{ 
    16 from deluge.ui.client import aclient 
    17 #get list of torrents 
    18  
    19 class TestClient: 
    20     def __init__(self): 
    21         self.torrent_ids = [] 
    22         self.torrent_status = [] 
    23  
    24     def cb_session_state(self, torrent_ids): 
    25         self.torrent_ids = torrent_ids 
    26  
    27     def cb_torrent_status(self, status): 
    28         self.torrent_status.append(status) 
    29  
    30     def run(self): 
    31         aclient.get_session_state(self.cb_session_state) 
    32         aclient.force_call(block=True) 
    33         print self.torrent_ids 
    34  
    35         for id in self.torrent_ids: 
    36             aclient.get_torrent_status(self.cb_torrent_status, id , []) 
    37         aclient.force_call(block=True) 
    38         for status in self.torrent_status: 
    39             print status 
    40  
    41 aclient.set_core_uri() 
    42 t = TestClient() 
    43 t.run() 
    44 }}} 
    459 
    4610== sclient == 
    4711The synchronous api. 
    4812 
    49 Simpler, but blocking the main thread. 
     13Simple, but blocking the main thread. 
    5014{{{ 
    5115from deluge.ui.client import sclient 
     
    5721}}} 
    5822 
     23== aclient == 
     24The asynchronous api. 
     25 
     26Used by rich user interfaces like gtk, or for performance critical batch-calls in webui. 
     27 
     28{{{ 
     29from deluge.ui.client import aclient 
     30#get list of torrents 
     31 
     32class TestClient: 
     33    def __init__(self): 
     34        self.torrent_ids = [] 
     35        self.torrent_status = [] 
     36 
     37    def cb_session_state(self, torrent_ids): 
     38        self.torrent_ids = torrent_ids 
     39 
     40    def cb_torrent_status(self, status): 
     41        self.torrent_status.append(status) 
     42 
     43    def run(self): 
     44        aclient.get_session_state(self.cb_session_state) 
     45        aclient.force_call(block=True) 
     46        print self.torrent_ids 
     47 
     48        for id in self.torrent_ids: 
     49            aclient.get_torrent_status(self.cb_torrent_status, id , []) 
     50        aclient.force_call(block=True) 
     51        for status in self.torrent_status: 
     52            print status 
     53 
     54aclient.set_core_uri() 
     55t = TestClient() 
     56t.run() 
     57}}} 
     58 
    5959 
    6060= Client Methods =