handling session timeout in onSessionTimeout evh

created new event handler onSessionTimeout, where
session timeout is handled. implemented for b2bua calls
sayer/1.4-spce2.6
Stefan Sayer 16 years ago
parent 471fc519bf
commit 7eb35d41c3

@ -314,6 +314,12 @@ void AmB2BSession::terminateOtherLeg()
clear_other();
}
void AmB2BSession::onSessionTimeout() {
DBG("Session Timer: Timeout, ending other leg.");
terminateOtherLeg();
AmSession::onSessionTimeout();
}
void AmB2BSession::relaySip(const AmSipRequest& req)
{
if (req.method != "ACK") {

@ -173,6 +173,8 @@ class AmB2BSession: public AmSession
void onSipReply(const AmSipReply& reply, int old_dlg_status);
void onInvite2xx(const AmSipReply& reply);
void onSessionTimeout();
/** @see AmEventQueue */
void process(AmEvent* event);

@ -684,13 +684,7 @@ void AmSession::onSipRequest(const AmSipRequest& req)
DBG("onSipRequest: method = %s\n",req.method.c_str());
if (refresh_method == REFRESH_UPDATE_FB_REINV) {
if (key_in_list(getHeader(req.hdrs, SIP_HDR_ALLOW),
SIP_METH_UPDATE)) {
DBG("remote allows UPDATE, using UPDATE for session refresh.\n");
refresh_method = REFRESH_UPDATE;
}
}
updateRefreshMethod(req.hdrs);
if(req.method == SIP_METH_INVITE){
@ -784,13 +778,7 @@ void AmSession::onSipReply(const AmSipReply& reply, int old_dlg_status)
{
CALL_EVENT_H(onSipReply,reply,old_dlg_status);
if (refresh_method == REFRESH_UPDATE_FB_REINV) {
if (key_in_list(getHeader(reply.hdrs, SIP_HDR_ALLOW),
SIP_METH_UPDATE)) {
DBG("remote allows UPDATE, using UPDATE for session refresh.\n");
refresh_method = REFRESH_UPDATE;
}
}
updateRefreshMethod(reply.hdrs);
if (old_dlg_status != dlg.getStatus())
DBG("Dialog status changed %s -> %s (stopped=%s) \n",
@ -1099,6 +1087,22 @@ void AmSession::onRtpTimeout()
setStopped();
}
void AmSession::onSessionTimeout() {
DBG("Session Timer: Timeout, ending session.\n");
dlg.bye();
setStopped();
}
void AmSession::updateRefreshMethod(const string& headers) {
if (refresh_method == REFRESH_UPDATE_FB_REINV) {
if (key_in_list(getHeader(headers, SIP_HDR_ALLOW),
SIP_METH_UPDATE)) {
DBG("remote allows UPDATE, using UPDATE for session refresh.\n");
refresh_method = REFRESH_UPDATE;
}
}
}
void AmSession::refresh() {
if (refresh_method == REFRESH_UPDATE) {
DBG("Refreshing session with UPDATE\n");

@ -181,8 +181,12 @@ public:
REFRESH_UPDATE, // use update
REFRESH_UPDATE_FB_REINV // use update or fallback to reinvite
};
/** currently selected session refresh method */
SessionRefreshMethod refresh_method;
/** update selected session refresh method from remote capabilities */
void updateRefreshMethod(const string& headers);
AmRtpAudio* RTPStream();
#ifdef WITH_ZRTP
@ -552,6 +556,10 @@ public:
/** This callback is called if RTP timeout encountered */
virtual void onRtpTimeout();
/** This callback is called if session
timeout encountered (session timers) */
virtual void onSessionTimeout();
/* Called by AmSipDialog when a request is sent */
virtual void onSendRequest(const string& method,
const string& content_type,

@ -347,11 +347,7 @@ void SessionTimer::onTimeoutEvent(AmTimeoutEvent* timeout_ev)
DBG("need session refresh but remote session is refresher\n");
}
} else if (timer_id == ID_SESSION_INTERVAL_TIMER) {
// // let the session know it got timeout
// onTimeout();
DBG("Session Timer: Timeout, ending session.\n");
s->dlg.bye();
s->setStopped();
s->onSessionTimeout();
} else {
DBG("unknown timeout event received.\n");
}

Loading…
Cancel
Save