#NEWLINE# def recvEvent( self , event ) : #NEWLINE# #INDENT# if isinstance ( event , CCEventRing ) : #NEWLINE# #INDENT# scode = event . getData ( ) #NEWLINE# if ( scode == None ) : #NEWLINE# #INDENT# ( code , reason , body ) = ( 180 , 'Ringing' , None ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( code , reason , body ) = scode #NEWLINE# if ( code == 100 ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# if ( ( body != None ) and ( self . ua . on_local_sdp_change != None ) and body . needs_update ) : #NEWLINE# #INDENT# self . ua . on_local_sdp_change ( body , ( lambda x : self . ua . recvEvent ( event ) ) ) #NEWLINE# return None #NEWLINE# #UNINDENT# #UNINDENT# self . ua . lSDP = body #NEWLINE# if ( self . ua . p1xx_ts == None ) : #NEWLINE# #INDENT# self . ua . p1xx_ts = event . rtime #NEWLINE# #UNINDENT# self . ua . sendUasResponse ( code , reason , body ) #NEWLINE# for ring_cb in self . ua . ring_cbs : #NEWLINE# #INDENT# ring_cb ( self . ua , event . rtime , event . origin , code ) #NEWLINE# #UNINDENT# return None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( event , CCEventConnect ) : #NEWLINE# #INDENT# ( code , reason , body ) = event . getData ( ) #NEWLINE# if ( ( body != None ) and ( self . ua . on_local_sdp_change != None ) and body . needs_update ) : #NEWLINE# #INDENT# self . ua . on_local_sdp_change ( body , ( lambda x : self . ua . recvEvent ( event ) ) ) #NEWLINE# return None #NEWLINE# #UNINDENT# self . ua . lSDP = body #NEWLINE# self . ua . sendUasResponse ( code , reason , body , self . ua . lContact ) #NEWLINE# if ( self . ua . expire_timer != None ) : #NEWLINE# #INDENT# self . ua . expire_timer . cancel ( ) #NEWLINE# self . ua . expire_timer = None #NEWLINE# #UNINDENT# self . ua . startCreditTimer ( event . rtime ) #NEWLINE# self . ua . connect_ts = event . rtime #NEWLINE# return ( UaStateConnected , self . ua . conn_cbs , event . rtime , event . origin ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( event , CCEventRedirect ) : #NEWLINE# #INDENT# scode = event . getData ( ) #NEWLINE# if ( scode == None ) : #NEWLINE# #INDENT# scode = ( 500 , 'Failed' , None , None ) #NEWLINE# #UNINDENT# self . ua . sendUasResponse ( scode [ 0 ] , scode [ 1 ] , scode [ 2 ] , SipContact ( address = SipAddress ( url = scode [ 3 ] ) ) ) #NEWLINE# if ( self . ua . expire_timer != None ) : #NEWLINE# #INDENT# self . ua . expire_timer . cancel ( ) #NEWLINE# self . ua . expire_timer = None #NEWLINE# #UNINDENT# self . ua . disconnect_ts = event . rtime #NEWLINE# return ( UaStateFailed , self . ua . fail_cbs , event . rtime , event . origin , scode [ 0 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( event , CCEventFail ) : #NEWLINE# #INDENT# scode = event . getData ( ) #NEWLINE# if ( scode == None ) : #NEWLINE# #INDENT# scode = ( 500 , 'Failed' ) #NEWLINE# #UNINDENT# self . ua . sendUasResponse ( scode [ 0 ] , scode [ 1 ] , reason_rfc3326 = event . reason , extra_header = event . extra_header ) #NEWLINE# if ( self . ua . expire_timer != None ) : #NEWLINE# #INDENT# self . ua . expire_timer . cancel ( ) #NEWLINE# self . ua . expire_timer = None #NEWLINE# #UNINDENT# self . ua . disconnect_ts = event . rtime #NEWLINE# return ( UaStateFailed , self . ua . fail_cbs , event . rtime , event . origin , scode [ 0 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( event , CCEventDisconnect ) : #NEWLINE# #INDENT# self . ua . sendUasResponse ( 500 , 'Disconnected' , reason_rfc3326 = event . reason ) #NEWLINE# if ( self . ua . expire_timer != None ) : #NEWLINE# #INDENT# self . ua . expire_timer . cancel ( ) #NEWLINE# self . ua . expire_timer = None #NEWLINE# #UNINDENT# self . ua . disconnect_ts = event . rtime #NEWLINE# return ( UaStateDisconnected , self . ua . disc_cbs , event . rtime , event . origin , self . ua . last_scode ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return None