<s> from twisted . internet . task import react <EOL> from twisted . internet . defer import inlineCallbacks as coroutine <EOL> from autobahn . twisted . wamp import Session <EOL> from autobahn . twisted . connection import Connection <EOL> def make_session ( config ) : <EOL> @ coroutine <EOL> def on_join ( session , details ) : <EOL> print ( "<STR_LIT>" . format ( details ) ) <EOL> def add2 ( a , b ) : <EOL> return a + b <EOL> yield session . register ( add2 , u'<STR_LIT>' ) <EOL> try : <EOL> res = yield session . call ( u'<STR_LIT>' , <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> print ( "<STR_LIT>" . format ( res ) ) <EOL> except Exception as e : <EOL> print ( "<STR_LIT>" . format ( e ) ) <EOL> finally : <EOL> session . leave ( ) <EOL> session = Session ( config = config ) <EOL> session . on ( '<STR_LIT>' , on_join ) <EOL> return session <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> session = make_session ( ) <EOL> connection = Connection ( ) <EOL> react ( connection . start , [ session ] ) </s>
