Changes between Version 7 and Version 8 of IpaacaTutorial


Ignore:
Timestamp:
12/10/13 12:11:10 (6 years ago)
Author:
yaghoubzadeh
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • IpaacaTutorial

    v7 v8  
    8383 
    8484 
     85{{{ 
     86import ipaaca 
     87import time 
     88 
     89# Define a handler. 
     90# Note: since we attach this handler only to an OutputBuffer, below, 
     91# we can expect to only receive remote updates (setting own == True) 
     92# No one stops you from attaching a handler to several different buffers though. 
     93def my_remote_update_handler(iu, event_type, own): 
     94        print( u'Received an update from the remote side.' ) 
     95        print( u'  Current payload is now: ' + unicode(iu.payload) ) 
     96 
     97myCategory = 'interestingCategory' 
     98print ( 'Will emit an IU of category '+ myCategory + 'and listen for 3 sec ...' ) 
     99 
     100my_outbuf = ipaaca.OutputBuffer('MyExampleSender') 
     101my_outbuf.register_handler(my_remote_update_handler) 
     102iu = ipaaca.IU(myCategory) 
     103iu.payload = { 'someKey':'initialValue',  'anotherKey':'12.345' } 
     104my_outbuf.add(iu) 
     105 
     106# wait 3 sec for any remote changes 
     107time.sleep(3) 
     108 
     109}}}