#NEWLINE# def __init__( self , main = None , setup = None , transports = None , config = None ) : #NEWLINE# #INDENT# '\n\n        :param main: A callable that runs user code for the component. The component will be\n            started with a "main-like" procedure. When a transport has been connected and\n            a session has been established and joined a realm, the user code will be run until it finishes\n            which signals that the component has run to completion.\n        :type main: callable\n        :param setup: A callable that runs user code for the component. The component will be\n            started with a "setup-like" procedure. When a transport has been connected and\n            a session has been established and joined a realm, the user code will be run until it finishes\n            which signals that the component is now "ready". The component will continue to run until\n            it explicitly closes the session or the underlying transport closes.\n        :type setup: callable\n        :param transports: Transport configurations for creating transports.\n        :type transports: None or unicode or list\n        :param config: Session configuration.\n        :type config: None or dict\n        ' #NEWLINE# ObservableMixin . __init__ ( self ) #NEWLINE# if ( ( main is None ) and ( setup is None ) ) : #NEWLINE# #INDENT# raise RuntimeError ( 'either a "main" or "setup" procedure must be provided for a component' ) #NEWLINE# #UNINDENT# if ( ( main is not None ) and ( setup is not None ) ) : #NEWLINE# #INDENT# raise RuntimeError ( 'either a "main" or "setup" procedure must be provided for a component (not both)' ) #NEWLINE# #UNINDENT# if ( ( main is not None ) and ( not callable ( main ) ) ) : #NEWLINE# #INDENT# raise RuntimeError ( '"main" must be a callable if given' ) #NEWLINE# #UNINDENT# if ( ( setup is not None ) and ( not callable ( setup ) ) ) : #NEWLINE# #INDENT# raise RuntimeError ( '"setup" must be a callable if given' ) #NEWLINE# #UNINDENT# if setup : #NEWLINE# #INDENT# self . _entry = setup #NEWLINE# self . _entry_type = Component . TYPE_SETUP #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if main : #NEWLINE# #INDENT# self . _entry = main #NEWLINE# self . _entry_type = Component . TYPE_MAIN #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# assert False , 'logic error' #NEWLINE# #UNINDENT# #UNINDENT# if ( transports is None ) : #NEWLINE# #INDENT# transports = 'ws://127.0.0.1:8080/ws' #NEWLINE# #UNINDENT# if ( type ( transports ) == six . text_type ) : #NEWLINE# #INDENT# url = transports #NEWLINE# ( is_secure , host , port , resource , path , params ) = parse_url ( url ) #NEWLINE# transport = { #NEWLINE# #INDENT# 'type' : 'websocket' , #NEWLINE# 'url' : url , #NEWLINE# 'endpoint' : { #NEWLINE# #INDENT# 'type' : 'tcp' , #NEWLINE# 'host' : host , #NEWLINE# 'port' : port , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# if is_secure : #NEWLINE# #INDENT# transport [ 'endpoint' ] [ 'tls' ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# transports = [ transport ] #NEWLINE# #UNINDENT# self . _transports = [ ] #NEWLINE# idx = 0 #NEWLINE# for transport in transports : #NEWLINE# #INDENT# check_transport ( transport ) #NEWLINE# self . _transports . append ( Transport ( idx , transport ) ) #NEWLINE# idx += 1 #NEWLINE# #UNINDENT# self . _realm = 'realm1' #NEWLINE# self . _extra = None