⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sip_invite_state.hxx.~3~

📁 模拟移动客户端软件飞信登录的状态机器定义代码。
💻 ~3~
字号:
//====================================================================//                // Copyright (C) 2006-2007,  Frank.Ning//                // Filename:      sip_invite_state.hxx// Author:        Frank.Ning <zegong.ning@dinglicom.com>// Description:   //                // $Id:$//                //====================================================================#ifndef __SIP_INVITE_STATE_HXX__#define __SIP_INVITE_STATE_HXX__#include "state.hxx"static const char* const sip_invite_state_hxx_version =   "$Id:$";struct sip_invite_state : public fsm::state<sip_invite_state, FetionInviteStateList, bool>{      bool on_process( shared_ptr<event> evt )      {         shared_ptr<sip_event> sip_evt;         sip_evt.reset( evt );         if( !sip_evt )            return false ;         shared_ptr<sip_msg> msg;                  msg.reset( sip_evt->get_msg( ) );                  if( !msg )            return true ;         shared_ptr<sip_cmd> cmd;         cmd.reset( msg );         if( cmd )            return on_process( cmd );         shared_ptr<sip_status> status ;         status.reset( msg );         if( status )            return on_process( status );         return false ;      }      bool on_process( shared_ptr<sip_cmd> cmd )      {         ua_callctl& ua = ua_callctl::instance( );         shared_ptr<sip_callid> callid;         callid.reset( cmd->get_hdr( HDR_CALLID ) );         shared_ptr<ua_agent> agent = ua.find_agent( callid->get_callid( ) );         if( !agent )            return false ;         agent->set_last_sip_cmd_msg( cmd );                  // check there is CANCEL command         if( cmd->get_method( ) == "C" ||             cmd->get_method( ) == "CANCEL" )         {            agent->stop( );            return true ;         }         if( agent->uas( ) )         {            shared_ptr<sip_status> trying_msg = agent->build_trying_msg( cmd );            // Ack to Proxy server            ua.get_output_channel( )->add( shared_ptr<sip_event>( trying_msg ) );            agent->set_last_sip_status_msg( trying_msg );                        // Ack to peer agent            shared_ptr<sip_status> ring_msg = agent->build_ring_msg( cmd );            ua.get_input_channel( )->add( shared_ptr<sip_event>( ring_msg ) ); // Send from ring state                     }         else         {            // UAC cmd is INVITE msg, send to            ua.get_output_channel( )->add( shared_ptr<sip_event>( cmd ) );         }                  switch_to<sip_ring_state>( );         return true ;      }      bool on_process( shared_ptr<sip_status> status )      {#if 0         ua_callctl& ua = ua_callctl::instance( );                  shared_ptr<sip_callid> callid;         callid.reset( cmd->get_hdr( HDR_CALLID ) );         shared_ptr<ua_agent> agent = ua.find_agent( callid->get_callid( ) );         if( !agent )            return false ;                     if( agent->uac( ) )            swicth_to<sip_ring_state>( );#endif         // there is not need to process          return true ;      }};#endif   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -