#NEWLINE# def __init__( self , connection , user_settings = dict ( ) , namespace = 'socket.io' , io_loop = None ) : #NEWLINE# #INDENT# "Constructor.\n\n        `connection`\n            SocketConnection class instance\n        `user_settings`\n            Settings\n        `namespace`\n            Router namespace, defaulted to 'socket.io'\n        `io_loop`\n            IOLoop instance, optional.\n        " #NEWLINE# if ( version_info [ 0 ] < 2 ) : #NEWLINE# #INDENT# raise Exception ( 'TornadIO2 requires Tornado 2.0 or higher.' ) #NEWLINE# #UNINDENT# self . _connection = connection #NEWLINE# self . io_loop = ( io_loop or ioloop . IOLoop . instance ( ) ) #NEWLINE# self . settings = DEFAULT_SETTINGS . copy ( ) #NEWLINE# if user_settings : #NEWLINE# #INDENT# self . settings . update ( user_settings ) #NEWLINE# #UNINDENT# self . _sessions = sessioncontainer . SessionContainer ( ) #NEWLINE# check_interval = ( self . settings [ 'session_check_interval' ] * 1000 ) #NEWLINE# self . _sessions_cleanup = ioloop . PeriodicCallback ( self . _sessions . expire , check_interval , self . io_loop ) #NEWLINE# self . _sessions_cleanup . start ( ) #NEWLINE# self . stats = stats . StatsCollector ( ) #NEWLINE# self . stats . start ( self . io_loop ) #NEWLINE# self . _transport_urls = [ ( ( '/%s/(?P<version>\\d+)/$' % namespace ) , HandshakeHandler , dict ( server = self ) ) ] #NEWLINE# for t in self . settings . get ( 'enabled_protocols' , dict ( ) ) : #NEWLINE# #INDENT# proto = PROTOCOLS . get ( t ) #NEWLINE# if ( not proto ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# self . _transport_urls . append ( ( ( '/%s/1/%s/(?P<session_id>[^/]+)/?' % ( namespace , t ) ) , proto , dict ( server = self ) ) )