-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from Bandwidth/DX-2703
DX-2703 Add `<StartStream>` and `<StopStream>` BXML Verbs
- Loading branch information
Showing
3 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
using System; | ||
using System.Xml; | ||
using System.Xml.Schema; | ||
using System.Xml.Serialization; | ||
|
||
namespace Bandwidth.Standard.Voice.Bxml | ||
{ | ||
/// <summary> | ||
/// The StartStream verb allows a segment of a call to be sent off to another destination for additional processing. | ||
/// <para><seealso href="https://dev.bandwidth.com/voice/bxml/startStream" /></para> | ||
/// </summary> | ||
public class StartStream : IXmlSerializable, IVerb, IAudioProducer | ||
{ | ||
/// <summary> | ||
/// A websocket URI to send the stream to | ||
/// </summary> | ||
public string Destination { get; set; } | ||
|
||
/// <summary> | ||
/// A name to refer to this stream by | ||
/// </summary> | ||
public string Name { get; set; } | ||
|
||
/// <summary> | ||
/// The part of the call to send a stream from. `inbound`, `outbound` or `both`. | ||
/// </summary> | ||
public string Tracks { get; set; } | ||
|
||
/// <summary> | ||
/// URL to send the associated Webhook events to during this stream's lifetime | ||
/// </summary> | ||
public string StreamEventUrl { get; set; } | ||
|
||
/// <summary> | ||
/// The HTTP method to use for the request to `streamEventUrl` | ||
/// </summary> | ||
public string StreamEventMethod { get; set; } | ||
|
||
/// <summary> | ||
/// The username to send in the HTTP request to `streamEventUrl` | ||
/// </summary> | ||
public string Username { get; set; } | ||
|
||
/// <summary> | ||
/// The password to send in the HTTP request to `streamEventUrl` | ||
/// </summary> | ||
public string Password { get; set; } | ||
|
||
XmlSchema IXmlSerializable.GetSchema() | ||
{ | ||
return null; | ||
} | ||
|
||
void IXmlSerializable.ReadXml(XmlReader reader) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
void IXmlSerializable.WriteXml(XmlWriter writer) | ||
{ | ||
writer.WriteAttributeString("destination", Destination); | ||
if (!string.IsNullOrEmpty(Name)) | ||
{ | ||
writer.WriteAttributeString("name", Name); | ||
} | ||
if (!string.IsNullOrEmpty(Tracks)) | ||
{ | ||
writer.WriteAttributeString("tracks", Tracks); | ||
} | ||
if (!string.IsNullOrEmpty(StreamEventUrl)) | ||
{ | ||
writer.WriteAttributeString("streamEventUrl", StreamEventUrl); | ||
} | ||
if (!string.IsNullOrEmpty(StreamEventMethod)) | ||
{ | ||
writer.WriteAttributeString("streamEventMethod", StreamEventMethod); | ||
} | ||
if (!string.IsNullOrEmpty(Username)) | ||
{ | ||
writer.WriteAttributeString("username", Username); | ||
} | ||
if (!string.IsNullOrEmpty(Password)) | ||
{ | ||
writer.WriteAttributeString("password", Password); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Xml; | ||
using System.Xml.Schema; | ||
using System.Xml.Serialization; | ||
|
||
namespace Bandwidth.Standard.Voice.Bxml | ||
{ | ||
/// <summary> | ||
/// The StopStream verb is used to stop a stream that was started with a previous `<StartStream>` verb. | ||
/// <para><seealso href="https://dev.bandwidth.com/voice/bxml/stopStream" /></para> | ||
/// </summary> | ||
public class StopStream : IXmlSerializable, IVerb, IAudioProducer | ||
{ | ||
/// <summary> | ||
/// The name of the stream to stop | ||
/// </summary> | ||
public string Name { get; set; } | ||
|
||
XmlSchema IXmlSerializable.GetSchema() | ||
{ | ||
return null; | ||
} | ||
|
||
void IXmlSerializable.ReadXml(XmlReader reader) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
void IXmlSerializable.WriteXml(XmlWriter writer) | ||
{ | ||
writer.WriteAttributeString("name", Name); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Bandwidth.Standard.Voice.Bxml; | ||
using Xunit; | ||
|
||
namespace Bandwidth.StandardTests.Voice.Bxml | ||
{ | ||
public class StreamTests | ||
{ | ||
|
||
[Fact] | ||
public void StartStreamBxmlVerbTest() | ||
{ | ||
var expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Response> <StartStream destination=\"https://www.test.com/stream\" name=\"test_stream\" tracks=\"inbound\" streamEventUrl=\"https://www.test.com/event\" streamEventMethod=\"POST\" username=\"username\" password=\"password\" /></Response>"; | ||
var startStream = new StartStream(); | ||
startStream.Destination = "https://www.test.com/stream"; | ||
startStream.Name = "test_stream"; | ||
startStream.Tracks = "inbound"; | ||
startStream.StreamEventUrl = "https://www.test.com/event"; | ||
startStream.StreamEventMethod = "POST"; | ||
startStream.Username = "username"; | ||
startStream.Password = "password"; | ||
|
||
var response = new Response(startStream); | ||
var actual = response.ToBXML(); | ||
|
||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[Fact] | ||
public void StopStreamBxmlVerbTest() | ||
{ | ||
var expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Response> <StopStream name=\"test_stream\" /></Response>"; | ||
var stopStream = new StopStream(); | ||
stopStream.Name = "test_stream"; | ||
|
||
var response = new Response(stopStream); | ||
var actual = response.ToBXML(); | ||
|
||
Assert.Equal(expected, actual); | ||
} | ||
} | ||
} |