📄 sip_register_state.hxx
字号:
//====================================================================// // Copyright (C) 2006-2007, Frank.Ning// // Filename: sip_register_state.hxx// Author: Frank.Ning <zegong.ning@dinglicom.com>// Description: // // $Id:$// //====================================================================#ifndef __SIP_REGISTER_STATE_HXX__#define __SIP_REGISTER_STATE_HXX__#include "state.hxx"static const char* const sip_register_state_hxx_version = "$Id:$";struct sip_register_state : public fsm::state<sip_register_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( ); ua.set_last_sip_reg_cmd( cmd ); ua.get_output_channel( )->add( shared_ptr<sip_event>( cmd ) ); return true ; } bool on_process( shared_ptr<sip_status> status ) { // Check is Register Message shared_ptr<sip_cseq> cseq ; cseq.reset( status->get_hdr( HDR_CSEQ ) ); if( cseq->get_method( ) != "R" ) return false; ua_callctl& ua = ua_callctl::instance( ); ua.set_last_sip_reg_status( status ); int status_code = status->get_status_code( ); if( status_code == 200 ) { // ua.set_register_success( true ); // Now we need to set regiter hold timer 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 ); switch_to<sip_register_hold_state>( ); return true ; } if( status_code == 400 ) { // Message format error ua.get_output_channel( )->add( shared_ptr<sip_event>( ua.get_last_sip_reg_cmd( ) ) ); return true ; } if( status_code == 401 ) { // Unauthorize // first check WWW-Authenticate shared_ptr<sip_www_authenticate> auth; auth.reset( status->get_hdr( HDR_WWW_AUTHENTICATE ) ); if( !auth ) { // Server is busy, must register delay 16 sec. ref 8.2.2.2 ua.get_output_channel( )->add( shared_ptr<sip_event>( ua.get_last_sip_reg_cmd( ) ), 16*1000 ); return true ; } ua.sip_register_with_author( status ); return true ; } if( status_code == 404 ) { // user is not in return true ; } }};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -