📄 sip_register_hold_state.hxx
字号:
//====================================================================// // Copyright (C) 2006-2007, Frank.Ning// // Filename: sip_register_hold_state.hxx// Author: Frank.Ning <zegong.ning@dinglicom.com>// Description: // // $Id:$// //====================================================================#ifndef __SIP_REGISTER_HOLD_STATE_HXX__#define __SIP_REGISTER_HOLD_STATE_HXX__static const char* const sip_register_hold_state_hxx_version = "$Id:$";#include "state.hxx"struct sip_register_hold_state : public fsm::state<sip_register_hold_state, FetionRegisterStateList, 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_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 ); return false ; } bool on_process( shared_ptr<sip_cmd> cmd ) { ua_callctl& ua = ua_callctrl::instance( ); if( cmd != ua.get_last_sip_reg_cmd( ) ) { ua.reset_agent( ); switch_to<sip_register_state>( ); } ua.get_output_channel( )->add( shared_ptr<sip_event>( cmd ) ); ua.set_last_sip_reg_cmd( cmd ); return true ; } bool on_process( shared_ptr<sip_status> status ) { ua_callctl& ua = ua_callctl::instance( ); shared_ptr<sip_cseq> cseq; cseq.reset( status->get_hdr( HDR_CSEQ ) ); if( cseq->get_method( ) != "R" || cseq->get_method( ) != "REGISTER" ) return false ; shared_ptr<sip_expires> expires; expires.reset( status->get_hdr( HDR_EXPIRES ) ); shared_ptr<sip_event> evt( ua.get_last_sip_reg_cmd( )->increase_cseq( ) ); ua.get_output_channel( )->add( evt, ( expires->get_delta_sec( ) - 90 ) * 1000 ); return true ; } bool on_process( shared_ptr<keyboard_msg> keyboard ) { ua_callctl& ua = ua_callctl::instance( ); if( keyboard->get_cmd( ) == "UNREGISTER" ) { shared_ptr<sip_cmd> unreg = ua.get_last_sip_reg_cmd( ); shared_ptr<sip_expires> expires; expires.reset( unreg->get_hdr( HDR_EXPIRES ) ); expires->set_delta_sec( 0 ); unreg->set_hdr( HDR_EXPIRES, expires ); ua.get_output_channel( )->add( shared_ptr<sip_event>( unreg ) ); ua.get_input_channel( )->add( shared_ptr<sip_event>( unreg ), 30*1000 ); switch_to<sip_unregister_state>( ); } return true ; } };#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -