From 664623210dc7bfc7e66e4c5085d4f476d2d30584 Mon Sep 17 00:00:00 2001 From: Audrey Copeland Date: Fri, 23 Jul 2021 09:16:07 -0400 Subject: [PATCH 1/4] EDGE-630 Add voiceCallId to generateTransferBxmlVerb for debugging --- src/WebRtc/Utils/WebRtcTransfer.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/WebRtc/Utils/WebRtcTransfer.php b/src/WebRtc/Utils/WebRtcTransfer.php index afe6229..13b6ac9 100644 --- a/src/WebRtc/Utils/WebRtcTransfer.php +++ b/src/WebRtc/Utils/WebRtcTransfer.php @@ -10,11 +10,11 @@ namespace BandwidthLib\WebRtc\Utils; class WebRtcTransfer { - public static function generateBxml($deviceToken, $sipUri = "sip:sipx.webrtc.bandwidth.com:5060") { - return '' . WebRtcTransfer::generateTransferBxmlVerb($deviceToken, $sipUri) . ''; + public static function generateBxml($deviceToken, $voiceCallId, $sipUri = "sip:sipx.webrtc.bandwidth.com:5060") { + return '' . WebRtcTransfer::generateTransferBxmlVerb($deviceToken, $voiceCallId, $sipUri) . ''; } - public static function generateTransferBxmlVerb($deviceToken, $sipUri = "sip:sipx.webrtc.bandwidth.com:5060") { - return '' . $sipUri . ''; + public static function generateTransferBxmlVerb($deviceToken, $voiceCallId, $sipUri = "sip:sipx.webrtc.bandwidth.com:5060") { + return '' . $sipUri . ''; } } From 684ebe0b9023bbf32c80ab9b064c56a8ead55555 Mon Sep 17 00:00:00 2001 From: Audrey Copeland Date: Fri, 23 Jul 2021 15:45:35 -0400 Subject: [PATCH 2/4] EDGE-630 Format the string to send to voice --- src/WebRtc/Utils/WebRtcTransfer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/WebRtc/Utils/WebRtcTransfer.php b/src/WebRtc/Utils/WebRtcTransfer.php index 13b6ac9..272272d 100644 --- a/src/WebRtc/Utils/WebRtcTransfer.php +++ b/src/WebRtc/Utils/WebRtcTransfer.php @@ -15,6 +15,7 @@ public static function generateBxml($deviceToken, $voiceCallId, $sipUri = "sip:s } public static function generateTransferBxmlVerb($deviceToken, $voiceCallId, $sipUri = "sip:sipx.webrtc.bandwidth.com:5060") { - return '' . $sipUri . ''; + $formattedCallId = substr(str_replace("-", "", $voiceCallId), 1); + return '' . $sipUri . ''; } } From 62f13c39520618ce65e733757e7dd4ac40eb764e Mon Sep 17 00:00:00 2001 From: Audrey Copeland Date: Fri, 23 Jul 2021 15:51:36 -0400 Subject: [PATCH 3/4] Add documentation and fix tests --- src/WebRtc/Utils/WebRtcTransfer.php | 12 ++++++++++++ tests/WebRtcBxmlTest.php | 8 ++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/WebRtc/Utils/WebRtcTransfer.php b/src/WebRtc/Utils/WebRtcTransfer.php index 272272d..6b1a0c9 100644 --- a/src/WebRtc/Utils/WebRtcTransfer.php +++ b/src/WebRtc/Utils/WebRtcTransfer.php @@ -11,10 +11,22 @@ class WebRtcTransfer { public static function generateBxml($deviceToken, $voiceCallId, $sipUri = "sip:sipx.webrtc.bandwidth.com:5060") { + /** + * Returns BXML string with WebRTC a device token to perform a SIP transfer + * @param string $deviceToken The device token + * @param array $voiceCallId The Bandwidth Voice Call Id + * @return string $sipUri The SIP URI to transfer the call to + */ return '' . WebRtcTransfer::generateTransferBxmlVerb($deviceToken, $voiceCallId, $sipUri) . ''; } public static function generateTransferBxmlVerb($deviceToken, $voiceCallId, $sipUri = "sip:sipx.webrtc.bandwidth.com:5060") { + /** + * Returns the Transfer verb to perform the SIP transfer + * @param string $deviceToken The device token + * @param array $voiceCallId The Bandwidth Voice Call Id + * @return string $sipUri The SIP URI to transfer the call to + */ $formattedCallId = substr(str_replace("-", "", $voiceCallId), 1); return '' . $sipUri . ''; } diff --git a/tests/WebRtcBxmlTest.php b/tests/WebRtcBxmlTest.php index f8cc7ad..64aa7ed 100644 --- a/tests/WebRtcBxmlTest.php +++ b/tests/WebRtcBxmlTest.php @@ -13,14 +13,14 @@ final class WebRtcBxmlTest extends TestCase { public function testGenerateBxml() { - $expected = 'sip:sipx.webrtc.bandwidth.com:5060'; - $actual = BandwidthLib\WebRtc\Utils\WebRtcTransfer::generateBxml('asdf'); + $expected = 'sip:sipx.webrtc.bandwidth.com:5060'; + $actual = BandwidthLib\WebRtc\Utils\WebRtcTransfer::generateBxml('asdf', 'c-93d6f3c0-be584596-0b74-4fa2-8015-d8ede84bd1a4'); $this->assertEquals($expected, $actual); } public function testGenerateTransferBxmlVerb() { - $expected = 'sip:sipx.webrtc.bandwidth.com:5060'; - $actual = BandwidthLib\WebRtc\Utils\WebRtcTransfer::generateTransferBxmlVerb('asdf'); + $expected = 'sip:sipx.webrtc.bandwidth.com:5060'; + $actual = BandwidthLib\WebRtc\Utils\WebRtcTransfer::generateTransferBxmlVerb('asdf', 'c-93d6f3c0-be584596-0b74-4fa2-8015-d8ede84bd1a4'); $this->assertEquals($expected, $actual); } } From ae5cd7549250cb9a1f2e6250b8b116ec3b02522b Mon Sep 17 00:00:00 2001 From: Audrey Copeland Date: Fri, 23 Jul 2021 15:53:15 -0400 Subject: [PATCH 4/4] Fix bug --- src/WebRtc/Utils/WebRtcTransfer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WebRtc/Utils/WebRtcTransfer.php b/src/WebRtc/Utils/WebRtcTransfer.php index 6b1a0c9..80537b9 100644 --- a/src/WebRtc/Utils/WebRtcTransfer.php +++ b/src/WebRtc/Utils/WebRtcTransfer.php @@ -28,6 +28,6 @@ public static function generateTransferBxmlVerb($deviceToken, $voiceCallId, $sip * @return string $sipUri The SIP URI to transfer the call to */ $formattedCallId = substr(str_replace("-", "", $voiceCallId), 1); - return '' . $sipUri . ''; + return '' . $sipUri . ''; } }