Skip to content

EDGE-630 Add voiceCallId to generateTransferBxmlVerb for debugging #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/WebRtc/Utils/WebRtcTransfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,24 @@
namespace BandwidthLib\WebRtc\Utils;

class WebRtcTransfer {
public static function generateBxml($deviceToken, $sipUri = "sip:sipx.webrtc.bandwidth.com:5060") {
return '<?xml version="1.0" encoding="UTF-8"?><Response>' . WebRtcTransfer::generateTransferBxmlVerb($deviceToken, $sipUri) . '</Response>';
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 '<?xml version="1.0" encoding="UTF-8"?><Response>' . WebRtcTransfer::generateTransferBxmlVerb($deviceToken, $voiceCallId, $sipUri) . '</Response>';
}

public static function generateTransferBxmlVerb($deviceToken, $sipUri = "sip:sipx.webrtc.bandwidth.com:5060") {
return '<Transfer><SipUri uui="' . $deviceToken . ';encoding=jwt">' . $sipUri . '</SipUri></Transfer>';
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 '<Transfer><SipUri uui="' . $formattedCallId . ';encoding=base64,' . $deviceToken . ';encoding=jwt">' . $sipUri . '</SipUri></Transfer>';
}
}
8 changes: 4 additions & 4 deletions tests/WebRtcBxmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
final class WebRtcBxmlTest extends TestCase
{
public function testGenerateBxml() {
$expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Transfer><SipUri uui="asdf;encoding=jwt">sip:sipx.webrtc.bandwidth.com:5060</SipUri></Transfer></Response>';
$actual = BandwidthLib\WebRtc\Utils\WebRtcTransfer::generateBxml('asdf');
$expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Transfer><SipUri uui="93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt">sip:sipx.webrtc.bandwidth.com:5060</SipUri></Transfer></Response>';
$actual = BandwidthLib\WebRtc\Utils\WebRtcTransfer::generateBxml('asdf', 'c-93d6f3c0-be584596-0b74-4fa2-8015-d8ede84bd1a4');
$this->assertEquals($expected, $actual);
}

public function testGenerateTransferBxmlVerb() {
$expected = '<Transfer><SipUri uui="asdf;encoding=jwt">sip:sipx.webrtc.bandwidth.com:5060</SipUri></Transfer>';
$actual = BandwidthLib\WebRtc\Utils\WebRtcTransfer::generateTransferBxmlVerb('asdf');
$expected = '<Transfer><SipUri uui="93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt">sip:sipx.webrtc.bandwidth.com:5060</SipUri></Transfer>';
$actual = BandwidthLib\WebRtc\Utils\WebRtcTransfer::generateTransferBxmlVerb('asdf', 'c-93d6f3c0-be584596-0b74-4fa2-8015-d8ede84bd1a4');
$this->assertEquals($expected, $actual);
}
}