Module: sems
Branch: master
Commit: f835212b385e4158c1536c3d1be0efc903f01970
URL: 
https://github.com/sems-server/sems/commit/f835212b385e4158c1536c3d1be0efc903f01970

Author: Juha Heinanen <[email protected]>
Committer: Juha Heinanen <[email protected]>
Date: 2016-04-30T15:01:51+03:00

core: added cancel function with hdrs argument to AmSipDialog

---

Modified: core/AmSipDialog.cpp
Modified: core/AmSipDialog.h

---

Diff:  
https://github.com/sems-server/sems/commit/f835212b385e4158c1536c3d1be0efc903f01970.diff
Patch: 
https://github.com/sems-server/sems/commit/f835212b385e4158c1536c3d1be0efc903f01970.patch

---

diff --git a/core/AmSipDialog.cpp b/core/AmSipDialog.cpp
index bec0602..213cf7a 100644
--- a/core/AmSipDialog.cpp
+++ b/core/AmSipDialog.cpp
@@ -517,7 +517,7 @@ AmSipRequest* AmSipDialog::getUASPendingInv()
 
 int AmSipDialog::bye(const string& hdrs, int flags)
 {
-    switch(status){
+  switch(status){
 
     case Disconnecting:
     case Connected: {
@@ -545,9 +545,9 @@ int AmSipDialog::bye(const string& hdrs, int flags)
     case Trying:
     case Proceeding:
     case Early:
-       if(getUACInvTransPending())
-           return cancel();
-       else {  
+      if(getUACInvTransPending())
+       return cancel(hdrs);
+      else {
            for (TransMap::iterator it=uas_trans.begin();
                 it != uas_trans.end(); it++) {
              if (it->second.method == SIP_METH_INVITE){
@@ -743,7 +743,7 @@ int AmSipDialog::cancel()
 {
     for(TransMap::reverse_iterator t = uac_trans.rbegin();
        t != uac_trans.rend(); t++) {
-       
+
        if(t->second.method == SIP_METH_INVITE){
 
          if(getStatus() != Cancelling){
@@ -762,6 +762,29 @@ int AmSipDialog::cancel()
     return -1;
 }
 
+int AmSipDialog::cancel(const string& hdrs)
+{
+    for(TransMap::reverse_iterator t = uac_trans.rbegin();
+       t != uac_trans.rend(); t++) {
+
+       if(t->second.method == SIP_METH_INVITE){
+
+         if(getStatus() != Cancelling){
+           setStatus(Cancelling);
+           return SipCtrlInterface::cancel(&t->second.tt, local_tag,
+                                           t->first, hdrs);
+         }
+         else {
+           ERROR("INVITE transaction has already been cancelled\n");
+           return -1;
+         }
+       }
+    }
+
+    ERROR("could not find INVITE transaction to cancel\n");
+    return -1;
+}
+
 int AmSipDialog::drop()
 {      
   setStatus(Disconnected);
diff --git a/core/AmSipDialog.h b/core/AmSipDialog.h
index 887940d..1da0cc6 100644
--- a/core/AmSipDialog.h
+++ b/core/AmSipDialog.h
@@ -113,6 +113,7 @@ class AmSipDialog
 
   /** @return 0 on success */
   int cancel();
+  int cancel(const string& hdrs);
 
   /** @return 0 on success */
   int prack(const AmSipReply &reply1xx,

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to