diff --git a/apps/examples/tutorial/mycc/MyCC.cpp b/apps/examples/tutorial/mycc/MyCC.cpp index 58426d39..c1232413 100644 --- a/apps/examples/tutorial/mycc/MyCC.cpp +++ b/apps/examples/tutorial/mycc/MyCC.cpp @@ -195,7 +195,7 @@ void MyCCDialog::process(AmEvent* ev) AmB2BCallerSession::process(ev); } -void MyCCDialog::onOtherReply(const AmSipReply& reply) { +bool MyCCDialog::onOtherReply(const AmSipReply& reply) { DBG("OnOtherReply \n"); if (state == CC_Dialing) { if (reply.code < 200) { @@ -226,6 +226,7 @@ void MyCCDialog::onOtherReply(const AmSipReply& reply) { // AmB2BCallerSession::onOtherReply(reply); // as it tears down the call if callee could // not be reached + return false; } void MyCCDialog::onOtherBye(const AmSipRequest& req) { diff --git a/apps/examples/tutorial/mycc/MyCC.h b/apps/examples/tutorial/mycc/MyCC.h index 327f165f..0b651295 100644 --- a/apps/examples/tutorial/mycc/MyCC.h +++ b/apps/examples/tutorial/mycc/MyCC.h @@ -61,7 +61,7 @@ class MyCCDialog : public AmB2BCallerSession void process(AmEvent* ev); void onBye(const AmSipRequest& req); protected: - void onOtherReply(const AmSipReply& reply); + bool onOtherReply(const AmSipReply& reply); void onOtherBye(const AmSipRequest& req); }; diff --git a/apps/ivr/Ivr.cpp b/apps/ivr/Ivr.cpp index 4e546973..7de6443c 100644 --- a/apps/ivr/Ivr.cpp +++ b/apps/ivr/Ivr.cpp @@ -717,11 +717,12 @@ void IvrDialog::onOtherBye(const AmSipRequest& req) AmB2BSession::onOtherBye(req); } -void IvrDialog::onOtherReply(const AmSipReply& r) +bool IvrDialog::onOtherReply(const AmSipReply& r) { if(callPyEventHandler("onOtherReply","is", r.code,r.reason.c_str())) AmB2BSession::onOtherReply(r); + return false; } void IvrDialog::onSipReply(const AmSipReply& r) { diff --git a/apps/ivr/Ivr.h b/apps/ivr/Ivr.h index 88ddceae..48593216 100644 --- a/apps/ivr/Ivr.h +++ b/apps/ivr/Ivr.h @@ -145,7 +145,7 @@ class IvrDialog : public AmB2BCallerSession void onDtmf(int event, int duration_msec); void onOtherBye(const AmSipRequest& req); - void onOtherReply(const AmSipReply& r); + bool onOtherReply(const AmSipReply& r); void onSipReply(const AmSipReply& r); void onSipRequest(const AmSipRequest& r); diff --git a/core/AmB2BSession.cpp b/core/AmB2BSession.cpp index 15ef0451..b8f0fcc4 100644 --- a/core/AmB2BSession.cpp +++ b/core/AmB2BSession.cpp @@ -178,10 +178,11 @@ void AmB2BSession::onOtherBye(const AmSipRequest& req) terminateLeg(); } -void AmB2BSession::onOtherReply(const AmSipReply& reply) +bool AmB2BSession::onOtherReply(const AmSipReply& reply) { if(reply.code >= 300) terminateLeg(); + return false; } void AmB2BSession::terminateLeg() @@ -233,6 +234,8 @@ void AmB2BCallerSession::terminateOtherLeg() void AmB2BCallerSession::onB2BEvent(B2BEvent* ev) { + bool processed = false; + if(ev->event_id == B2BSipReply){ AmSipReply& reply = ((B2BSipReplyEvent*)ev)->reply; @@ -268,7 +271,7 @@ void AmB2BCallerSession::onB2BEvent(B2BEvent* ev) terminateOtherLeg(); } - onOtherReply(reply); + processed = onOtherReply(reply); break; default: @@ -277,7 +280,8 @@ void AmB2BCallerSession::onB2BEvent(B2BEvent* ev) } } - AmB2BSession::onB2BEvent(ev); + if (!processed) + AmB2BSession::onB2BEvent(ev); } void AmB2BCallerSession::relayEvent(AmEvent* ev) diff --git a/core/AmB2BSession.h b/core/AmB2BSession.h index b4db070b..02d93b5c 100644 --- a/core/AmB2BSession.h +++ b/core/AmB2BSession.h @@ -151,8 +151,12 @@ class AmB2BSession: public AmSession // Other leg received a BYE virtual void onOtherBye(const AmSipRequest& req); - /** INVITE from other leg has been replied */ - virtual void onOtherReply(const AmSipReply& reply); + /** + * Reply received from other leg has been replied + * @return true if reply was processed (should be absorbed) + * @return false if reply was not processed + */ + virtual bool onOtherReply(const AmSipReply& reply); AmB2BSession() : sip_relay_only(true)