-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmodule-rtc-quickconnect.html
359 lines (339 loc) · 29.1 KB
/
module-rtc-quickconnect.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<title>rtc.io</title>
<link rel="stylesheet" type="text/css" href="css/reset.css">
<link rel="stylesheet" type="text/css" href="css/main.css">
<!-- responsive -->
<link rel="stylesheet" media="screen and (max-width: 960px)" href="css/tablet.css">
<link rel="stylesheet" media="screen and (max-width: 710px)" href="css/phone.css">
<link rel="stylesheet" type="text/css" href="fonts/source-sans/stylesheet.css">
<link rel="stylesheet" type="text/css" href="css/code.css">
</head>
<body>
<a class="scroll-point pt-top" name="top"></a>
<header>
<a href="https://github.com/rtc-io/rtc-quickconnect"><img class="fork" src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png" alt="Fork me on GitHub"></a>
<a class="scroll-point pt-top" name="top"></a>
<div class="site">
<div class="mascot">
<img src="images/artsio.png">
</div>
<div class="logo" data-subtext="OpenSource WebRTC">
<a href="index.html">rtc.io</a>
</div>
<nav>
<ul>
<li><a href="index.html">About</a></li>
<li><a href="tutorials.html">Tutorials</a></li>
<li><a href="demos.html">Demos</a></li>
<li><a href="modules.html">Modules</a></li>
</ul>
</nav>
</div>
<div class="shadow"></div>
</header>
<div class="main" role="content"><h1 id="rtc-quickconnect">rtc-quickconnect</h1>
<p>This is a high level helper module designed to help you get up
an running with WebRTC really, really quickly. By using this module you
are trading off some flexibility, so if you need a more flexible
configuration you should drill down into lower level components of the
<a href="http://www.rtc.io">rtc.io</a> suite. In particular you should check out
<a href="https://github.com/rtc-io/rtc">rtc</a>.</p>
<p><a href="https://nodei.co/npm/rtc-quickconnect/"><img src="https://nodei.co/npm/rtc-quickconnect.png" alt="NPM"></a></p>
<p><a href="https://travis-ci.org/rtc-io/rtc-quickconnect"><img src="https://img.shields.io/travis/rtc-io/rtc-quickconnect.svg?branch=master" alt="Build Status"></a> <a href="https://github.com/dominictarr/stability#unstable"><img src="https://img.shields.io/badge/stability-unstable-yellowgreen.svg" alt="unstable"></a>
<a href="https://groups.google.com/forum/#!forum/rtc-io"><img src="http://img.shields.io/badge/discuss-rtc.io-blue.svg" alt="rtc.io google group"></a></p>
<h2 id="example-usage">Example Usage</h2>
<p>In the simplest case you simply call quickconnect with a single string
argument which tells quickconnect which server to use for signaling:</p>
<div class="highlight"><pre><span class="kd">var</span> <span class="nx">quickconnect</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'rtc-quickconnect'</span><span class="p">);</span>
<span class="nx">quickconnect</span><span class="p">(</span><span class="s1">'https://switchboard.rtc.io/'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">room</span><span class="o">:</span> <span class="s1">'qc-simple-demo'</span> <span class="p">})</span>
<span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">'call:started'</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">id</span><span class="p">,</span> <span class="nx">pc</span><span class="p">,</span> <span class="nx">data</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">'we have a new connection to: '</span> <span class="o">+</span> <span class="nx">id</span><span class="p">);</span>
<span class="p">});</span>
</pre></div>
<h2 id="events">Events</h2>
<p>The following events are emitted from the signalling object created by calling <code>quickconnect()</code>. Additionally, any of the underlying <a href="https://github.com/rtc-io/rtc-signaller#signaller-events">signaller events</a> can also be used.</p>
<h3 id="peer-level-events">Peer Level Events</h3>
<p>The peer level events provided in quickconnect provide you the ability to tap into the various stages of the lifecycle for connecting with a peer, before the connection actually migrates to the status of a connected "call".</p>
<ul>
<li><p><code>peer:connect => function(id, peerconnection, data)</code></p>
<p>The <code>peer:connect</code> event is emitted when we first create a connection to a discovered peer. The <code>peerconnection</code> argument is a standard <code>RTCPeerConnection</code> instance.</p>
</li>
<li><p><code>peer:couple => funtion(id, peerconnection, data, monitor)</code></p>
<p>The <code>peer:couple</code> event is emitted when once quickconnect has <a href="https://github.com/rtc-io/rtc-tools#rtc-toolscouple">coupled</a> to it's remote counterpart.</p>
</li>
</ul>
<h3 id="call-level-events">Call Level Events</h3>
<p>A "call" in quickconnect is equivalent to an established <code>RTCPeerConnection</code> between this quickconnect instance a remote peer.</p>
<ul>
<li><p><code>call:started => function(id, peerconnection, data)</code></p>
<p>Triggered once a peer connection has been established been established between this quickconnect instance and another.</p>
</li>
<li><p><code>call:ended => function(id)</code></p>
<p>Triggered when a peer connection has been closed. This may be due to the peer connection itself indicating that it has been closed, or we may have lost connection with the remote signaller and the connection has timed out.</p>
</li>
</ul>
<h3 id="data-channel-level-events">Data Channel Level Events</h3>
<ul>
<li><p><code>channel:opened => function(id, datachannel, data)</code></p>
<p>The <code>channel:opened</code> event is triggered whenever an <code>RTCDataChannel</code> has been opened (it's ready to send data) to a remote peer.</p>
</li>
<li><p><code>channel:opened:%label% => function(id, datachannel, data)</code></p>
<p>This is equivalent of the <code>channel:opened</code> event, but only triggered for a channel with label <code>%label%</code>. For example:</p>
<div class="highlight"><pre><span class="nx">quickconnect</span><span class="p">(</span><span class="s1">'https://switchboard.rtc.io/'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">room</span><span class="o">:</span> <span class="s1">'test'</span> <span class="p">})</span>
<span class="p">.</span><span class="nx">createDataChannel</span><span class="p">(</span><span class="s1">'foo'</span><span class="p">)</span>
<span class="p">.</span><span class="nx">createDataChannel</span><span class="p">(</span><span class="s1">'bar'</span><span class="p">)</span>
<span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">'channel:opened:foo'</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">id</span><span class="p">,</span> <span class="nx">dc</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">'channel foo opened for peer: '</span> <span class="o">+</span> <span class="nx">id</span><span class="p">);</span>
<span class="p">});</span>
</pre></div>
<p>In the case above the console message would only be displayed for the <code>foo</code> channel once open, and when the <code>bar</code> channel is opened no handler would be invoked.</p>
</li>
<li><p><code>channel:closed => function(id, datachannel, label)</code></p>
<p>Emitted when the channel has been closed, works when a connection has been closed or the channel itself has been closed.</p>
</li>
<li><p><code>channel:closed:%label% => function(id, datachannel, label)</code></p>
<p>The label specific equivalent of <code>channel:closed</code>.</p>
</li>
</ul>
<h3 id="stream-level-events">Stream Level Events</h3>
<ul>
<li><p><code>stream:added => function(id, stream, data)</code></p>
<p>The <code>stream:added</code> event is triggered when an <code>RTCPeerConnection</code> has successfully been established to another peer that contains remote streams. Additionally, if you are using quickconnect in it's "reactive" mode then you will also receive <code>stream:added</code> events as streams are dynamically added to the connection by the remote peer.</p>
</li>
<li><p><code>stream:removed => function(id)</code></p>
<p>As per the <code>stream:added</code> event but triggered when a stream has been removed.</p>
</li>
</ul>
<h2 id="example-usage-using-data-channels-">Example Usage (using data channels)</h2>
<p>When working with WebRTC data channels, you can call the <code>createDataChannel</code> function helper that is attached to the object returned from the <code>quickconnect</code> call. The <code>createDataChannel</code> function signature matches the signature of the <code>RTCPeerConnection</code> <code>createDataChannel</code> function.</p>
<p>At the minimum it requires a label for the channel, but you can also pass through a dictionary of options that can be used to fine tune the data channel behaviour. For more information on these options, I'd recommend having a quick look at the WebRTC spec:</p>
<p><a href="http://dev.w3.org/2011/webrtc/editor/webrtc.html#dictionary-rtcdatachannelinit-members">http://dev.w3.org/2011/webrtc/editor/webrtc.html#dictionary-rtcdatachannelinit-members</a></p>
<p>If in doubt, I'd recommend not passing through options.</p>
<div class="highlight"><pre><span class="kd">var</span> <span class="nx">freeice</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'freeice'</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">quickconnect</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'rtc-quickconnect'</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">opts</span> <span class="o">=</span> <span class="p">{</span>
<span class="nx">room</span><span class="o">:</span> <span class="s1">'qcexample-dctest'</span><span class="p">,</span>
<span class="c1">// debug: true,</span>
<span class="nx">iceServers</span><span class="o">:</span> <span class="nx">freeice</span><span class="p">()</span>
<span class="p">};</span>
<span class="nx">quickconnect</span><span class="p">(</span><span class="s1">'https://switchboard.rtc.io/'</span><span class="p">,</span> <span class="nx">opts</span><span class="p">)</span>
<span class="c1">// tell quickconnect we want a datachannel called test</span>
<span class="p">.</span><span class="nx">createDataChannel</span><span class="p">(</span><span class="s1">'test'</span><span class="p">)</span>
<span class="c1">// when the test channel is open, let us know</span>
<span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">'channel:opened:test'</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">id</span><span class="p">,</span> <span class="nx">dc</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">dc</span><span class="p">.</span><span class="nx">onmessage</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">evt</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">'peer '</span> <span class="o">+</span> <span class="nx">id</span> <span class="o">+</span> <span class="s1">' says: '</span> <span class="o">+</span> <span class="nx">evt</span><span class="p">.</span><span class="nx">data</span><span class="p">);</span>
<span class="p">};</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">'test dc open for peer: '</span> <span class="o">+</span> <span class="nx">id</span><span class="p">);</span>
<span class="nx">dc</span><span class="p">.</span><span class="nx">send</span><span class="p">(</span><span class="s1">'hi'</span><span class="p">);</span>
<span class="p">});</span>
</pre></div>
<h2 id="example-usage-using-captured-media-">Example Usage (using captured media)</h2>
<p>Another example is displayed below, and this example demonstrates how to use <code>rtc-quickconnect</code> to create a simple video conferencing application:</p>
<div class="highlight"><pre><span class="kd">var</span> <span class="nx">quickconnect</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'rtc-quickconnect'</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">crel</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'crel'</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">getUserMedia</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'getusermedia'</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">attachmediastream</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'attachmediastream'</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">qsa</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'fdom/qsa'</span><span class="p">);</span>
<span class="c1">// create containers for our local and remote video</span>
<span class="kd">var</span> <span class="nx">local</span> <span class="o">=</span> <span class="nx">crel</span><span class="p">(</span><span class="s1">'div'</span><span class="p">,</span> <span class="p">{</span> <span class="kr">class</span><span class="o">:</span> <span class="s1">'local'</span> <span class="p">});</span>
<span class="kd">var</span> <span class="nx">remote</span> <span class="o">=</span> <span class="nx">crel</span><span class="p">(</span><span class="s1">'div'</span><span class="p">,</span> <span class="p">{</span> <span class="kr">class</span><span class="o">:</span> <span class="s1">'remote'</span> <span class="p">});</span>
<span class="kd">var</span> <span class="nx">peerMedia</span> <span class="o">=</span> <span class="p">{};</span>
<span class="c1">// once media is captured, connect</span>
<span class="nx">getUserMedia</span><span class="p">({</span> <span class="nx">audio</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span> <span class="nx">video</span><span class="o">:</span> <span class="kc">true</span> <span class="p">},</span> <span class="kd">function</span><span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">localStream</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">console</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="s1">'could not capture media: '</span><span class="p">,</span> <span class="nx">err</span><span class="p">);</span>
<span class="p">}</span>
<span class="c1">// render the local media</span>
<span class="nx">local</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">attachmediastream</span><span class="p">(</span><span class="nx">localStream</span><span class="p">));</span>
<span class="c1">// initiate connection</span>
<span class="nx">quickconnect</span><span class="p">(</span><span class="s1">'https://switchboard.rtc.io/'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">room</span><span class="o">:</span> <span class="s1">'conftest'</span> <span class="p">})</span>
<span class="c1">// broadcast our captured media to other participants in the room</span>
<span class="p">.</span><span class="nx">addStream</span><span class="p">(</span><span class="nx">localStream</span><span class="p">)</span>
<span class="c1">// when a peer is connected (and active) pass it to us for use</span>
<span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">'call:started'</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">id</span><span class="p">,</span> <span class="nx">pc</span><span class="p">,</span> <span class="nx">data</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">videos</span> <span class="o">=</span> <span class="nx">pc</span><span class="p">.</span><span class="nx">getRemoteStreams</span><span class="p">().</span><span class="nx">map</span><span class="p">(</span><span class="nx">attachmediastream</span><span class="p">);</span>
<span class="nx">videos</span><span class="p">.</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">video</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">video</span><span class="p">.</span><span class="nx">dataset</span><span class="p">.</span><span class="nx">peer</span> <span class="o">=</span> <span class="nx">id</span><span class="p">;</span>
<span class="nx">remote</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">video</span><span class="p">);</span>
<span class="p">});</span>
<span class="p">})</span>
<span class="c1">// when a peer leaves, remove teh media</span>
<span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">'call:ended'</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">id</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">qsa</span><span class="p">(</span><span class="s1">'*[data-peer="'</span> <span class="o">+</span> <span class="nx">id</span> <span class="o">+</span> <span class="s1">'"]'</span><span class="p">,</span> <span class="nx">remote</span><span class="p">).</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">el</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">el</span><span class="p">.</span><span class="nx">parentNode</span><span class="p">.</span><span class="nx">removeChild</span><span class="p">(</span><span class="nx">el</span><span class="p">);</span>
<span class="p">});</span>
<span class="p">});</span>
<span class="p">});</span>
<span class="cm">/* extra code to handle dynamic html and css creation */</span>
<span class="c1">// add some basic styling</span>
<span class="nb">document</span><span class="p">.</span><span class="nx">head</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">crel</span><span class="p">(</span><span class="s1">'style'</span><span class="p">,</span> <span class="p">[</span>
<span class="s1">'.local { position: absolute; right: 10px; }'</span><span class="p">,</span>
<span class="s1">'.local video { max-width: 200px; }'</span>
<span class="p">].</span><span class="nx">join</span><span class="p">(</span><span class="s1">'\n'</span><span class="p">)));</span>
<span class="c1">// add the local and remote elements</span>
<span class="nb">document</span><span class="p">.</span><span class="nx">body</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">local</span><span class="p">);</span>
<span class="nb">document</span><span class="p">.</span><span class="nx">body</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">remote</span><span class="p">);</span>
</pre></div>
<h2 id="regarding-signalling-and-a-signalling-server">Regarding Signalling and a Signalling Server</h2>
<p>Signaling is an important part of setting up a WebRTC connection and for
our examples we use our own test instance of the
<a href="https://github.com/rtc-io/rtc-switchboard">rtc-switchboard</a>. For your
testing and development you are more than welcome to use this also, but
just be aware that we use this for our testing so it may go up and down
a little. If you need something more stable, why not consider deploying
an instance of the switchboard yourself - it's pretty easy :)</p>
<h2 id="reference">Reference</h2>
<pre><code>quickconnect(signalhost, opts?) => rtc-sigaller instance (+ helpers)</code></pre>
<h3 id="valid-quick-connect-options">Valid Quick Connect Options</h3>
<p>The options provided to the <code>rtc-quickconnect</code> module function influence the
behaviour of some of the underlying components used from the rtc.io suite.</p>
<p>Listed below are some of the commonly used options:</p>
<ul>
<li><p><code>ns</code> (default: '')</p>
<p>An optional namespace for your signalling room. While quickconnect
will generate a unique hash for the room, this can be made to be more
unique by providing a namespace. Using a namespace means two demos
that have generated the same hash but use a different namespace will be
in different rooms.</p>
</li>
<li><p><code>room</code> (default: null) <em>added 0.6</em></p>
<p>Rather than use the internal hash generation
(plus optional namespace) for room name generation, simply use this room
name instead. <strong>NOTE:</strong> Use of the <code>room</code> option takes precendence over
<code>ns</code>.</p>
</li>
<li><p><code>debug</code> (default: false)</p>
</li>
</ul>
<p>Write rtc.io suite debug output to the browser console.</p>
<ul>
<li><p><code>expectedLocalStreams</code> (default: not specified) <em>added 3.0</em></p>
<p>By providing a positive integer value for this option will mean that
the created quickconnect instance will wait until the specified number of
streams have been added to the quickconnect "template" before announcing
to the signaling server.</p>
</li>
<li><p><code>manualJoin</code> (default: <code>false</code>)</p>
<p>Set this value to <code>true</code> if you would prefer to call the <code>join</code> function
to connecting to the signalling server, rather than having that happen
automatically as soon as quickconnect is ready to.</p>
</li>
</ul>
<h4 id="options-for-peer-connection-creation">Options for Peer Connection Creation</h4>
<p>Options that are passed onto the
<a href="https://github.com/rtc-io/rtc#createconnectionopts-constraints">rtc.createConnection</a>
function:</p>
<ul>
<li><code>iceServers</code></li>
</ul>
<p>This provides a list of ice servers that can be used to help negotiate a
connection between peers.</p>
<h4 id="options-for-p2p-negotiation">Options for P2P negotiation</h4>
<p>Under the hood, quickconnect uses the
<a href="https://github.com/rtc-io/rtc#rtccouple">rtc/couple</a> logic, and the options
passed to quickconnect are also passed onto this function.</p>
<h3 id="quickconnect-broadcast-and-data-channel-helper-functions">Quickconnect Broadcast and Data Channel Helper Functions</h3>
<p>The following are functions that are patched into the <code>rtc-signaller</code>
instance that make working with and creating functional WebRTC applications
a lot simpler.</p>
<h4 id="addstream">addStream</h4>
<pre><code>addStream(stream:MediaStream) => qc</code></pre>
<p>Add the stream to active calls and also save the stream so that it
can be added to future calls.</p>
<h4 id="endcalls-">endCalls()</h4>
<p>The <code>endCalls</code> function terminates all the active calls that have been
created in this quickconnect instance. Calling <code>endCalls</code> does not
kill the connection with the signalling server.</p>
<h4 id="close-">close()</h4>
<p>The <code>close</code> function provides a convenient way of closing all associated
peer connections. This function simply uses the <code>endCalls</code> function and
the underlying <code>leave</code> function of the signaller to do a "full cleanup"
of all connections.</p>
<h4 id="createdatachannel-label-config-">createDataChannel(label, config)</h4>
<p>Request that a data channel with the specified <code>label</code> is created on
the peer connection. When the data channel is open and available, an
event will be triggered using the label of the data channel.</p>
<p>For example, if a new data channel was requested using the following
call:</p>
<div class="highlight"><pre><span class="kd">var</span> <span class="nx">qc</span> <span class="o">=</span> <span class="nx">quickconnect</span><span class="p">(</span><span class="s1">'https://switchboard.rtc.io/'</span><span class="p">).</span><span class="nx">createDataChannel</span><span class="p">(</span><span class="s1">'test'</span><span class="p">);</span>
</pre></div>
<p>Then when the data channel is ready for use, a <code>test:open</code> event would
be emitted by <code>qc</code>.</p>
<h4 id="join-">join()</h4>
<p>The <code>join</code> function is used when <code>manualJoin</code> is set to true when creating
a quickconnect instance. Call the <code>join</code> function once you are ready to
join the signalling server and initiate connections with other people.</p>
<h4 id="-get-name-"><code>get(name)</code></h4>
<p>The <code>get</code> function returns the property value for the specified property name.</p>
<h4 id="-getlocalstreams-"><code>getLocalStreams()</code></h4>
<p>Return a copy of the local streams that have currently been configured</p>
<h4 id="reactive-">reactive()</h4>
<p>Flag that this session will be a reactive connection.</p>
<h4 id="removestream">removeStream</h4>
<pre><code>removeStream(stream:MediaStream)</code></pre>
<p>Remove the specified stream from both the local streams that are to
be connected to new peers, and also from any active calls.</p>
<h4 id="requestchannel">requestChannel</h4>
<pre><code>requestChannel(targetId, label, callback)</code></pre>
<p>This is a function that can be used to respond to remote peers supplying
a data channel as part of their configuration. As per the <code>receiveStream</code>
function this function will either fire the callback immediately if the
channel is already available, or once the channel has been discovered on
the call.</p>
<h4 id="requeststream">requestStream</h4>
<pre><code>requestStream(targetId, idx, callback)</code></pre>
<p>Used to request a remote stream from a quickconnect instance. If the
stream is already available in the calls remote streams, then the callback
will be triggered immediately, otherwise this function will monitor
<code>stream:added</code> events and wait for a match.</p>
<p>In the case that an unknown target is requested, then an exception will
be thrown.</p>
<h4 id="profile-data-">profile(data)</h4>
<p>Update the profile data with the attached information, so when
the signaller announces it includes this data in addition to any
room and id information.</p>
<h4 id="waitforcall">waitForCall</h4>
<pre><code>waitForCall(targetId, callback)</code></pre>
<p>Wait for a call from the specified targetId. If the call is already
active the callback will be fired immediately, otherwise we will wait
for a <code>call:started</code> event that matches the requested <code>targetId</code></p>
<h2 id="license-s-">License(s)</h2>
<h3 id="apache-2-0">Apache 2.0</h3>
<p>Copyright 2015 National ICT Australia Limited (NICTA)</p>
<p> Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at</p>
<pre><code> http://www.apache.org/licenses/LICENSE-2.0</code></pre>
<p> Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.</p>
</div>
<footer>
<p>
<a href="http://nicta.com.au">
<img src="images/nicta-logo.gif" alt="NICTA logo">
</a>© NICTA 2013 - 2014
</p>
<p class="license">Project source code is licensed under the <a href="https://github.com/rtc-io/rtc/blob/master/LICENSE">Apache 2.0</a>.</p>
<a class="closing" href="#top"></a>
</footer>
</body>
<script src="js/app.js"></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-26567546-2', 'rtc.io');
ga('send', 'pageview');
</script>
</html>