<s> from nodeset . core import node , message <EOL> from nodeset . common . twistedapi import run <EOL> from twisted . application import service <EOL> from twisted . internet import reactor <EOL> class TMessage ( message . NodeMessage ) : <EOL> def __init__ ( self ) : <EOL> message . NodeMessage . __init__ ( self ) <EOL> message . Attribute ( '<STR_LIT>' ) <EOL> class SimpleNode ( node . Node ) : <EOL> def onEvent ( self , event_name , msg ) : <EOL> return "<STR_LIT>" % ( event_name , msg ) <EOL> def _print ( rval ) : <EOL> print rval <EOL> def _publish ( n , name , payload ) : <EOL> n . publish ( name , TMessage , payload = payload ) . addCallback ( _print ) <EOL> def publish_main ( ) : <EOL> n = SimpleNode ( <NUM_LIT> ) <EOL> application = service . Application ( '<STR_LIT>' ) <EOL> reactor . callLater ( <NUM_LIT:1> , n . subscribe , '<STR_LIT>' ) <EOL> reactor . callLater ( <NUM_LIT:2> , _publish , n , '<STR_LIT>' , '<STR_LIT>' ) <EOL> reactor . callLater ( <NUM_LIT:2> , _publish , n , '<STR_LIT>' , '<STR_LIT>' ) <EOL> reactor . callLater ( <NUM_LIT:4> , _publish , n , '<STR_LIT>' , '<STR_LIT>' ) <EOL> n . start ( ) <EOL> n . setServiceParent ( application ) <EOL> run ( application ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> publish_main ( ) </s>
