📄 siptransactioninviteclient.cxx
字号:
MRef<SipResponse*> resp = (SipResponse *)*command.getCommandPacket(); dispatcher->enqueueCommand( cmd, HIGH_PRIO_QUEUE/*, PRIO_LAST_IN_QUEUE*/ ); //assert(dialog); //TODO/XXX/FIXME: Do this in the TU instead //dialog->dialogState.updateState( resp ); //rel1xxProcessing(resp); return true; }else{ return false; }}//TODO: make sure transport_error is sent when it should bebool SipTransactionInviteClient::a7_proceeding_terminated_2xx( const SipSMCommand &command){ if (transitionMatch(SipResponse::type, command, SipSMCommand::transport_layer, SipSMCommand::transaction_layer, "2**")){ cancelTimeout("timerA"); cancelTimeout("timerB"); SipSMCommand cmd( command.getCommandPacket(), SipSMCommand::transaction_layer, SipSMCommand::dialog_layer); dispatcher->enqueueCommand( cmd, HIGH_PRIO_QUEUE/*, PRIO_LAST_IN_QUEUE*/ ); //update dialogs route set ... needed to add route headers to the ACK we are going to send //setDialogRouteSet( (SipResponse*)*command.getCommandPacket() ); //assert(dialog); //TODO/XXX/FIXME: In Tu instead //dialog->dialogState.updateState( (MRef<SipResponse*>((SipResponse *)*command.getCommandPacket()) ) ); SipSMCommand cmdterminated( CommandString( callId, SipCommandString::transaction_terminated), SipSMCommand::transaction_layer, SipSMCommand::dispatcher); dispatcher->enqueueCommand( cmdterminated, HIGH_PRIO_QUEUE/*, PRIO_FIRST_IN_QUEUE*/ ); return true; }else{ return false; }}bool SipTransactionInviteClient::a8_proceeding_completed_resp36( const SipSMCommand &command){ if (transitionMatch(SipResponse::type, command, SipSMCommand::transport_layer, SipSMCommand::transaction_layer, "3**\n4**\n5**\n6**")){ MRef<SipResponse *> resp((SipResponse*)*command.getCommandPacket()); cancelTimeout("timerA"); cancelTimeout("timerB"); if( isUnreliable() ) requestTimeout(sipStack->getTimers()->getD(),"timerD"); else requestTimeout( 0,"timerD"); SipSMCommand cmd( command.getCommandPacket(), SipSMCommand::transaction_layer, SipSMCommand::dialog_layer); dispatcher->enqueueCommand( cmd, HIGH_PRIO_QUEUE/*, PRIO_LAST_IN_QUEUE*/ ); //assert(dialog); //IN TU instead TODO/XXX/FIXME //dialog->dialogState.updateState( resp ); sendAck(resp); return true; }else{ return false; }}bool SipTransactionInviteClient::a9_completed_completed_resp36( const SipSMCommand &command){ if (transitionMatch(SipResponse::type, command, SipSMCommand::transport_layer, SipSMCommand::transaction_layer, "3**\n4**\n5**\n6**")){ MRef<SipResponse *> resp((SipResponse*)*command.getCommandPacket()); sendAck(resp); return true; }else{ return false; }}bool SipTransactionInviteClient::a10_completed_terminated_TErr( const SipSMCommand &command){ if (transitionMatch(command, SipCommandString::transport_error, SipSMCommand::transaction_layer, SipSMCommand::transaction_layer)){ cancelTimeout("timerD"); SipSMCommand cmd( CommandString( callId, SipCommandString::transport_error), SipSMCommand::transaction_layer, SipSMCommand::dialog_layer); dispatcher->enqueueCommand( cmd, HIGH_PRIO_QUEUE/*, PRIO_LAST_IN_QUEUE*/ ); SipSMCommand cmdterminated( CommandString( callId, SipCommandString::transaction_terminated), SipSMCommand::transaction_layer, SipSMCommand::dispatcher); dispatcher->enqueueCommand( cmdterminated, HIGH_PRIO_QUEUE/*, PRIO_FIRST_IN_QUEUE*/ ); return true; }else{ return false; }}bool SipTransactionInviteClient::a11_completed_terminated_timerD( const SipSMCommand &command){ if (transitionMatch(command, "timerD", SipSMCommand::transaction_layer, SipSMCommand::transaction_layer)){ SipSMCommand cmd( CommandString( callId, SipCommandString::transaction_terminated), SipSMCommand::transaction_layer, SipSMCommand::dispatcher); dispatcher->enqueueCommand( cmd, HIGH_PRIO_QUEUE/*, PRIO_FIRST_IN_QUEUE*/ ); return true; }else{ return false; }}void SipTransactionInviteClient::setUpStateMachine(){ State<SipSMCommand,string> *s_start=new State<SipSMCommand,string>(this,"start"); addState(s_start); State<SipSMCommand,string> *s_calling=new State<SipSMCommand,string>(this,"calling"); addState(s_calling); State<SipSMCommand,string> *s_proceeding=new State<SipSMCommand,string>(this,"proceeding"); addState(s_proceeding); State<SipSMCommand,string> *s_completed=new State<SipSMCommand,string>(this,"completed"); addState(s_completed); State<SipSMCommand,string> *s_terminated=new State<SipSMCommand,string>(this,"terminated"); addState(s_terminated); //Set up cancel transitions new StateTransition<SipSMCommand,string>(this, "transition_cancel_transaction", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransaction::a1000_anyState_terminated_canceltransaction, StateMachine<SipSMCommand,string>::anyState, s_terminated); // new StateTransition<SipSMCommand,string>(this, "transition_start_calling_INVITE", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteClient::a0_start_calling_INVITE, s_start, s_calling); new StateTransition<SipSMCommand,string>(this, "transition_calling_calling_timerA", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteClient::a1_calling_calling_timerA, s_calling, s_calling); new StateTransition<SipSMCommand,string>(this, "transition_calling_proceeding_1xx", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteClient::a2_calling_proceeding_1xx, s_calling, s_proceeding); new StateTransition<SipSMCommand,string>(this, "transition_calling_completed_resp36", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteClient::a3_calling_completed_resp36, s_calling, s_completed); new StateTransition<SipSMCommand,string>(this, "transition_calling_terminated_ErrOrTimerB", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteClient::a4_calling_terminated_ErrOrTimerB, s_calling, s_terminated); new StateTransition<SipSMCommand,string>(this, "transition_calling_terminated_2xx", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteClient::a5_calling_terminated_2xx, s_calling, s_terminated); new StateTransition<SipSMCommand,string>(this, "transition_proceeding_proceeding_1xx", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteClient::a6_proceeding_proceeding_1xx, s_proceeding, s_proceeding); new StateTransition<SipSMCommand,string>(this, "transition_proceeding_terminated_2xx", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteClient::a7_proceeding_terminated_2xx, s_proceeding, s_terminated); new StateTransition<SipSMCommand,string>(this, "transition_proceeding_completed_resp36", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteClient::a8_proceeding_completed_resp36, s_proceeding, s_completed); new StateTransition<SipSMCommand,string>(this, "transition_completed_completed_resp36", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteClient::a9_completed_completed_resp36, s_completed, s_completed); new StateTransition<SipSMCommand,string>(this, "transition_completed_terminated_TErr", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteClient::a10_completed_terminated_TErr, s_completed, s_terminated); new StateTransition<SipSMCommand,string>(this, "transition_completed_terminated_timerD", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteClient::a11_completed_terminated_timerD, s_completed, s_terminated); setCurrentState(s_start);}SipTransactionInviteClient::SipTransactionInviteClient(MRef<SipStack*> stack, //MRef<SipDialog*> call, int seq_no, const string &cSeqMethod, const string &callid): SipTransactionClient(stack, /*call,*/ seq_no, cSeqMethod, "", callid), lastInvite(NULL){// MRef<SipCommonConfig *> conf;// if (dialog){// conf = dialog->getDialogConfig()->inherited;// }else{// conf = sipStack->getStackConfig();// } timerA=sipStack->getTimers()->getA(); //toaddr = conf->sipIdentity->getSipProxy()->sipProxyIpAddr->clone(); //port = getConfig()->sipIdentity->getSipProxy()->sipProxyPort; setUpStateMachine();}SipTransactionInviteClient::~SipTransactionInviteClient(){}void SipTransactionInviteClient::setDialogRouteSet(MRef<SipResponse *> ) {#if 0 assert(dialog); if( dialog->dialogState.routeSet.size() == 0 ) { //merr << "CESC: parent dialog has NO routeset" << end; /*SipMessage::getRouteSet returns the uris in the record-route headers, in the top to bottom order. We need to reverse the order of those uris (as client).*/ dialog->dialogState.routeSet = resp->getRouteSet(); dialog->dialogState.routeSet.reverse(); //for( list<string>::iterator iter = dialog->dialogState.routeSet.begin(); iter!=dialog->dialogState.routeSet.end(); iter++ ) { // merr << "CESC: SipTransINVCli:setrouteset: " << (*iter) << end; //} } else { //merr << "CESC: parent dialog already has a routeset" << end; }#endif}void SipTransactionInviteClient::sendAck(MRef<SipResponse*> resp, string br, bool provisional){// MRef<SipCommonConfig *> conf;// if (dialog){// conf = dialog->getDialogConfig()->inherited;// }else{// conf = sipStack->getStackConfig();// } //merr << "CESC: SipTransInvClie:sendACK : dialogstate.remoteUri=" << dialog->dialogState.remoteUri << end; MRef<SipMessage*> ref( *resp); MRef<SipRequest*> ack= SipRequest::createSipMessageAck( br, ref, //dialog->dialogState.getRemoteTarget(), //FIXME: uses dialog here, but it could be NULL ref->getTo().getRequestUriString(), provisional ); if (provisional){ //TODO/XXX/FIXME: What is this needed for? --EE //int seq = dialog->dialogState.seqNo++; //((SipHeaderValueCSeq*)*ack->getHeaderValueNo(SIP_HEADER_TYPE_CSEQ, 0))->setCSeq(seq); } //add route headers, if needed //TODO/XXX/FIXME: in TU instead/* if( dialog->dialogState.routeSet.size() > 0 ) { //merr << "CESC: SipTransInvCli:sendACK : adding header route! " << end; MRef<SipHeaderValueRoute *> rset = new SipHeaderValueRoute (dialog->dialogState.routeSet); ack->addHeader(new SipHeader(*rset) ); } else { //merr << "CESC: SipTransInvCli::sendACK : dialog route set is EMPTY!!! " << end; }*/ send(MRef<SipMessage*>(*ack), true, br);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -