Skip to content
This repository was archived by the owner on Aug 15, 2024. It is now read-only.

Commit 513f5d0

Browse files
author
Craig Dennis
authored
Merge pull request #827 from TwilioDevEd/add-connect-stream
Adds Connect Stream TwiML examples
2 parents b540c37 + e4d9817 commit 513f5d0

8 files changed

Lines changed: 80 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const VoiceResponse = require('twilio').twiml.VoiceResponse;
2+
3+
const response = new VoiceResponse();
4+
const connect = response.connect();
5+
connect.stream({
6+
url: 'wss://mystream.ngrok.io/audiostream'
7+
});
8+
9+
console.log(response.toString());
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using Twilio.TwiML;
3+
using Twilio.TwiML.Voice;
4+
5+
6+
class Example
7+
{
8+
static void Main()
9+
{
10+
var response = new VoiceResponse();
11+
var connect = new Connect();
12+
connect.Stream(url: "wss://mystream.ngrok.io/audiostream");
13+
response.Append(connect);
14+
15+
Console.WriteLine(response.ToString());
16+
}
17+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
require_once './vendor/autoload.php';
3+
use Twilio\TwiML\VoiceResponse;
4+
5+
$response = new VoiceResponse();
6+
$connect = $response->connect();
7+
$connect->stream(['url' => 'wss://mystream.ngrok.io/audiostream']);
8+
9+
echo $response;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
require 'twilio-ruby'
2+
3+
response = Twilio::TwiML::VoiceResponse.new
4+
response.connect do |connect|
5+
connect.stream(url: 'wss://mystream.ngrok.io/audiostream')
6+
end
7+
8+
puts response
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from twilio.twiml.voice_response import Connect, VoiceResponse, Stream
2+
3+
response = VoiceResponse()
4+
connect = Connect()
5+
connect.stream(url='wss://mystream.ngrok.io/audiostream')
6+
response.append(connect)
7+
8+
print(response)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import com.twilio.twiml.voice.Connect;
2+
import com.twilio.twiml.VoiceResponse;
3+
import com.twilio.twiml.voice.Stream;
4+
import com.twilio.twiml.TwiMLException;
5+
6+
7+
public class Example {
8+
public static void main(String[] args) {
9+
Stream stream = new Stream.Builder().url("wss://mystream.ngrok.io/audiostream").build();
10+
Connect connect = new Connect.Builder().stream(stream).build();
11+
VoiceResponse response = new VoiceResponse.Builder().connect(connect).build();
12+
13+
try {
14+
System.out.println(response.toXml());
15+
} catch (TwiMLException e) {
16+
e.printStackTrace();
17+
}
18+
}
19+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"title": "Connect a Programmable Voice call to a bi-directional Media Stream",
3+
"type": "server"
4+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Response>
3+
<Connect>
4+
<Stream url="wss://mystream.ngrok.io/audiostream" />
5+
</Connect>
6+
</Response>

0 commit comments

Comments
 (0)