#NEWLINE# def on_connected( self , headers , body ) : #NEWLINE# #INDENT# "\n        Once the connection is established, and 'heart-beat' is found in the headers, we calculate the real\n        heartbeat numbers (based on what the server sent and what was specified by the client) - if the heartbeats\n        are not 0, we start up the heartbeat loop accordingly.\n\n        :param headers: headers in the connection message\n        :param body: the message body\n        " #NEWLINE# if ( 'heart-beat' in headers ) : #NEWLINE# #INDENT# self . heartbeats = utils . calculate_heartbeats ( headers [ 'heart-beat' ] . replace ( ' ' , '' ) . split ( ',' ) , self . heartbeats ) #NEWLINE# if ( self . heartbeats != ( 0 , 0 ) ) : #NEWLINE# #INDENT# self . send_sleep = ( self . heartbeats [ 0 ] / 1000 ) #NEWLINE# self . receive_sleep = ( ( self . heartbeats [ 1 ] / 1000 ) * 1.5 ) #NEWLINE# if ( self . receive_sleep != 0 ) : #NEWLINE# #INDENT# self . received_heartbeat = ( monotonic ( ) + ( 2 * headers . receive_sleep ) ) #NEWLINE# #UNINDENT# if ( self . send_sleep == 0 ) : #NEWLINE# #INDENT# self . sleep_time = self . receive_sleep #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . receive_sleep == 0 ) : #NEWLINE# #INDENT# self . sleep_time = self . send_sleep #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . sleep_time = ( gcd ( self . send_sleep , self . receive_sleep ) / 2.0 ) #NEWLINE# #UNINDENT# #UNINDENT# self . running = True #NEWLINE# if ( self . heartbeat_thread is None ) : #NEWLINE# #INDENT# self . heartbeat_thread = utils . default_create_thread ( self . __heartbeat_loop ) #NEWLINE# self . heartbeat_thread . name = ( 'StompHeartbeat%s' % getattr ( self . heartbeat_thread , 'name' , 'Thread' ) )