📄 sip_ring_state.hxx.~2~
字号:
//====================================================================// // Copyright (C) 2006-2007, Frank.Ning// // Filename: sip_ring_state.hxx// Author: Frank.Ning <zegong.ning@dinglicom.com>// Description: // // $Id:$// //====================================================================#ifndef __SIP_RING_STATE_HXX__#define __SIP_RING_STATE_HXX__static const char* const sip_ring_state_hxx_version = "$Id:$";#include "state.hxx"struct sip_ring_state : public fsm::state<sip_ring_state, FetionInviteStateList, bool>{ bool on_process( shared_ptr<event> evt ) { shared_ptr<sip_event> sip_evt; sip_evt.reset( evt ); if( sip_evt ) { shared_ptr<sip_cmd> cmd; cmd.reset( sip_evt->get_msg( ) ); if( cmd ) return on_process( cmd ); shared_ptr<sip_status> status; status.reset( sip_evt->get_msg( ) ); if( status ) return on_process( status ); } shared_ptr<keyborad_event> kevt; kevt.reset( evt ); if( kevt ) return on_process( kevt->get_msg( ) ); 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 ); if( cmd->get_method( ) == "C" || cmd->get_method( ) == "CANCEL" ) { if( agent->uac( ) ) ua.get_output_channel( )->add( shared_ptr<sip_event>( cmd ) ); agent->stop( ); return true ; } return true ; } bool on_process( shared_ptr<sip_status> status ) { 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_status_msg( status ); if( status->get_status_code( ) == 180 ) // ringing { if( agent->uas( ) ) ua.get_output_channel( )->add( shared_ptr<sip_event>( status ) ); } return true ; } bool on_process( shared_ptr<keyboard_msg> keyboard ) { ua_callctl& ua = ua_callctl::instance( ); shared_ptr<ua_agent> agent = ua.find_agent( keyboard->get_callid( ) ); switch( keyboard->get_cmd( ) ) { case "ACCEPT": { shared_ptr<sip_status> status = agent->build_ok_msg( agent->get_last_sip_cmd_msg( ) ); agent->set_last_sip_status_msg( status ); ua.get_output_channel( )->add( shared_ptr<sip_event>( status ) ); switch_to<sip_incall_state>( ); break ; } case "CANCEL": { shared_ptr<sip_cmd> cancel = agent->build_cancel_msg( agent->get_last_sip_cmd_msg( ) ); ua.get_output_channel( )->add( shared_ptr<sip_event>( cancel ) ); agent->set_last_sip_cmd_msg( cancel ); agent->stop( ); break ; } default: break; } return true ; }};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -