<s> from __future__ import print_function <EOL> from os import environ <EOL> from twisted . internet import reactor <EOL> from twisted . internet . defer import inlineCallbacks <EOL> from autobahn . twisted . wamp import ApplicationSession , ApplicationRunner <EOL> class Component ( ApplicationSession ) : <EOL> """<STR_LIT>""" <EOL> @ inlineCallbacks <EOL> def onJoin ( self , details ) : <EOL> print ( "<STR_LIT>" ) <EOL> self . received = <NUM_LIT:0> <EOL> sub = yield self . subscribe ( self . on_event , u'<STR_LIT>' ) <EOL> print ( "<STR_LIT>" . format ( sub . id ) ) <EOL> def on_event ( self , i ) : <EOL> print ( "<STR_LIT>" . format ( i ) ) <EOL> self . received += <NUM_LIT:1> <EOL> if self . received > self . config . extra [ '<STR_LIT>' ] : <EOL> print ( "<STR_LIT>" ) <EOL> self . leave ( ) <EOL> def onDisconnect ( self ) : <EOL> print ( "<STR_LIT>" ) <EOL> if reactor . running : <EOL> reactor . stop ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> runner = ApplicationRunner ( <EOL> environ . get ( "<STR_LIT>" , u"<STR_LIT>" ) , <EOL> u"<STR_LIT>" , <EOL> extra = dict ( <EOL> max_events = <NUM_LIT:5> , <EOL> ) , <EOL> ) <EOL> runner . run ( Component ) </s>
