From 2fac679018aa044cd15ef768110271f3c3836bf8 Mon Sep 17 00:00:00 2001 From: ethaniel Date: Sun, 14 Jul 2024 20:03:38 +0700 Subject: [PATCH] Update PhpSIP.class.php --- PhpSIP.class.php | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/PhpSIP.class.php b/PhpSIP.class.php index 804547d..a8d4e44 100644 --- a/PhpSIP.class.php +++ b/PhpSIP.class.php @@ -753,6 +753,17 @@ public function send() } } + if (substr($this->res_code,0,1) == '1' && $this->res_code != '183') + { + $i = 0; + while (substr($this->res_code,0,1) == '1' && $this->res_code != '183' && $i < 4) + { + $this->readMessage(); + $i++; + } + } + + if ($this->res_code == '407') { $this->cseq++; @@ -779,15 +790,6 @@ public function send() $this->readMessage(); } - if (substr($this->res_code,0,1) == '1' && $this->res_code != '183') - { - $i = 0; - while (substr($this->res_code,0,1) == '1' && $this->res_code != '183' && $i < 4) - { - $this->readMessage(); - $i++; - } - } $this->extra_headers = array(); $this->cseq++; @@ -954,6 +956,15 @@ private function readMessage() $this->dialog = $this->from_tag.'.'.$this->to_tag.'.'.$this->call_id; } } + + /** + * Wait for message and return the result code + */ + + public function getCode() { + $this->readMessage(); + return $this->res_code; + } /** * Parse Response