@ -205,28 +205,28 @@ void AmSessionContainer::destroySession(AmSession* s)
}
}
string AmSessionContainer : : startSessionUAC ( const AmSipRequest & req , string & app_name , const AmArg * session_params ) {
string AmSessionContainer : : startSessionUAC ( const AmSipRequest & req , string & app_name , const AmArg * session_params )
{
unique_ptr < AmSession > session ;
try {
session . reset ( createSession ( req , app_name , session_params ) ) ;
if ( session . get ( ) ! = 0 ) {
session - > dlg - > initFromLocalRequest ( req ) ;
session - > setCallgroup ( req . from_tag ) ;
switch ( addSession ( req . from_tag , session . get ( ) ) ) {
switch ( addSession ( req . from_tag , session . get ( ) ) )
{
case AmSessionContainer : : Inserted :
// successful case
/* successful case */
break ;
case AmSessionContainer : : ShutDown :
throw AmSession : : Exception ( AmConfig : : ShutdownModeErrCode ,
AmConfig : : ShutdownModeErrReason ) ;
throw AmSession : : Exception ( AmConfig : : ShutdownModeErrCode , AmConfig : : ShutdownModeErrReason ) ;
case AmSessionContainer : : AlreadyExist :
throw AmSession : : Exception ( 482 ,
SIP_REPLY_LOOP_DETECTED ) ;
throw AmSession : : Exception ( 482 , SIP_REPLY_LOOP_DETECTED ) ;
default :
ERROR ( " adding session to session container \n " ) ;
@ -248,9 +248,9 @@ string AmSessionContainer::startSessionUAC(const AmSipRequest& req, string& app_
}
if ( AmConfig : : LogSessions ) {
INFO ( " Starting UAC session %s app %s \n " ,
req . from_tag . c_str ( ) , app_name . c_str ( ) ) ;
INFO ( " Starting UAC session %s app %s \n " , req . from_tag . c_str ( ) , app_name . c_str ( ) ) ;
}
try {
session - > start ( ) ;
} catch ( . . . ) {
@ -279,38 +279,35 @@ string AmSessionContainer::startSessionUAC(const AmSipRequest& req, string& app_
void AmSessionContainer : : startSessionUAS ( AmSipRequest & req )
{
try {
// Call-ID and From-Tag are unknown: it's a new session
/* Call-ID and From-Tag are unknown: it's a new session */
unique_ptr < AmSession > session ;
string app_name ;
session . reset ( createSession ( req , app_name ) ) ;
if ( session . get ( ) ! = 0 ) {
// update session's local tag (ID) if not already set
if ( session . get ( ) ! = 0 ) {
/* update session's local tag (ID) if not already set */
session - > setLocalTag ( ) ;
const string & local_tag = session - > getLocalTag ( ) ;
// by default each session is in its own callgroup
/* by default each session is in its own callgroup */
session - > setCallgroup ( local_tag ) ;
if ( AmConfig : : LogSessions ) {
INFO ( " Starting UAS session %s \n " ,
local_tag . c_str ( ) ) ;
INFO ( " Starting UAS session %s \n " , local_tag . c_str ( ) ) ;
}
switch ( addSession ( req . callid , req . from_tag , local_tag ,
req . via_branch , session . get ( ) ) ) {
switch ( addSession ( req . callid , req . from_tag , local_tag , req . via_branch , session . get ( ) ) )
{
case AmSessionContainer : : Inserted :
// successful case
/* successful case */
break ;
case AmSessionContainer : : ShutDown :
throw AmSession : : Exception ( AmConfig : : ShutdownModeErrCode ,
AmConfig : : ShutdownModeErrReason ) ;
throw AmSession : : Exception ( AmConfig : : ShutdownModeErrCode , AmConfig : : ShutdownModeErrReason ) ;
case AmSessionContainer : : AlreadyExist :
throw AmSession : : Exception ( 482 ,
SIP_REPLY_LOOP_DETECTED ) ;
throw AmSession : : Exception ( 482 , SIP_REPLY_LOOP_DETECTED ) ;
default :
ERROR ( " adding session to session container \n " ) ;
@ -326,8 +323,7 @@ void AmSessionContainer::startSessionUAS(AmSipRequest& req)
try {
session - > start ( ) ;
} catch ( . . . ) {
AmEventDispatcher : : instance ( ) - >
delEventQueue ( local_tag ) ;
AmEventDispatcher : : instance ( ) - > delEventQueue ( local_tag ) ;
throw ;
}