diff --git a/core/AmSession.cpp b/core/AmSession.cpp index 92d68314..d67a6794 100644 --- a/core/AmSession.cpp +++ b/core/AmSession.cpp @@ -241,6 +241,15 @@ void AmSession::setUri(const string& uri) sdp.uri = uri; } +void AmSession::setLocalTag() +{ + if (dlg.local_tag.empty()) { + dlg.local_tag = getNewId(); + DBG("AmSession::setLocalTag() - session id set to %s\n", + dlg.local_tag.c_str()); + } +} + void AmSession::setLocalTag(const string& tag) { DBG("AmSession::setLocalTag(%s)\n",tag.c_str()); diff --git a/core/AmSession.h b/core/AmSession.h index 8a35a804..a6a7aac8 100644 --- a/core/AmSession.h +++ b/core/AmSession.h @@ -286,6 +286,9 @@ public: /** Gets the Session's local tag */ const string& getLocalTag() const; + /** Sets the Session's local tag if not set already */ + void setLocalTag(); + /** Sets the Session's local tag */ void setLocalTag(const string& tag); diff --git a/core/AmSessionContainer.cpp b/core/AmSessionContainer.cpp index f755406f..819f5147 100644 --- a/core/AmSessionContainer.cpp +++ b/core/AmSessionContainer.cpp @@ -233,22 +233,18 @@ void AmSessionContainer::startSessionUAS(AmSipRequest& req) AmSession* session; if((session = createSession(req)) != 0){ - string local_tag = AmSession::getNewId(); - session->setLocalTag(local_tag); + // 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 session->setCallgroup(local_tag); session->start(); addSession_unsafe(req.callid,req.from_tag,local_tag,session); session->postEvent(new AmSipRequestEvent(req)); } - //else - //throw AmSession::Exception(500,"internal error"); } } - // catch(const AmSession::SessionTimerException& e){ - // ERROR("%i %s\n",e.code,e.reason.c_str()); - // AmSipDialog::reply_error(req,e.code,e.reason,e.getErrorHeaders()); - // } catch(const AmSession::Exception& e){ ERROR("%i %s\n",e.code,e.reason.c_str()); AmSipDialog::reply_error(req,e.code,e.reason);