-
Notifications
You must be signed in to change notification settings - Fork 3
/
jssdk.html
executable file
·407 lines (382 loc) · 28 KB
/
jssdk.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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, shrink-to-fit=no, initial-scale=1">
<meta name="description" content="Circuit Developer Community - JS SDK Examples">
<meta name="author" content="Roger Urscheler">
<link rel="shortcut icon" type="image/png" href="images/js-logo.png"/>
<title>Circuit API JS SDK Examples</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<script>
if (window.location.host == 'circuit.github.io' && window.location.protocol != 'https:') {
window.location.protocol = 'https:';
}
</script>
</head>
<body>
<div id="wrapper">
<!-- Sidebar -->
<div id="sidebar-wrapper"></div>
<!-- Page Content -->
<div id="page-content-wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<h1>JavaScript SDK</h1>
<p>When running the examples you will be asked to sign in with a Circuit sandbox account.</p>
<a href="https://eu.yourcircuit.com/sdk" target="_blank" class="btn btn-default">API Documentation</a>
<a href="https://github.com/circuit/circuit-sdk" target="_blank" class="btn btn-default">GitHub</a><br><br>
<p>Example to logon and fetch conversations:</p>
<pre class="prettyprint">
// Create the client with the client_id (aka app key), scope and optionally a redirect_uri
const client = new Circuit.Client({
client_id: 'your client_id',
scope: 'READ_USER_PROFILE,READ_CONVERSATIONS'
});
// Logon with OAuth2, then retrieve the logged on user's conversations
client.logon()
.then(user => console.log('Successfully authenticated as ' + user.displayName))
.then(client.getConversations)
.then(conversations => conversations.forEach(c => console.log(c.convId)))
.catch(console.error);
</pre>
<p>See <a href="oauth.html">OAuth 2.0</a> for information on how to register an app.</p>
</div>
</div>
<!-- Examples -->
<div class="row">
<div class="col-lg-12">
<h2 class="page-header">Examples</h2>
</div>
</div>
<div class="row" id="plunker">
<div class="col-lg-12">
<h3>Plunker examples</h3>
<p>Short examples demonstrating one or more particular APIs. You can view the source, or fork your own plunker. A sandbox account is required to run the live examples. JS Bin examples use OAuth 2.0.</p>
<table class="table table-condensed">
<thead>
<tr>
<th>Live Example</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="https://plnkr.co/edit/STMZA8?p=preview" target="_blank">Direct call with realtime webrtc stats</a></td>
<td>Initiate a direct audio, video or HD video call. Answer incoming call. Display basic or raw WebRTC stats.</td>
</tr>
<tr>
<td><a href="https://plnkr.co/edit/2T9Z0v?p=preview" target="_blank">Configure Voicemail</a></td>
<td>Enable/disable voicemail, Set voicemail timeout, Enable/disable custom voicemail greeting, Upload custom greeting file, Get custom greeting url.</td>
</tr>
<tr>
<td><a href="https://plnkr.co/edit/KRVEfU?p=preview" target="_blank">Subscribe to user presence</a></td>
<td>Retrieve pages of conversations to get most recent direct conversations, then subscribe to the presence of those users and keep their status up to date.</td>
</tr>
<tr>
<td><a href="https://plnkr.co/edit/pV5iNQhEvElO04u9VIGV?p=preview" target="_blank">Mentioning</a></td>
<td>Retrieves the ten most recent conversations, send and receive messages in the selected conversation, mention other users by typing "@" then their name, receive notifications if mentioned by other users in the listed conversations.</td>
</tr>
<tr>
<td><a href="https://plnkr.co/edit/ib7nyQdNLHaaRAZMXwWL?p=preview" target="_blank">Label Management</a></td>
<td>Add new labels, edit existing labels, remove existing labels. Displays a list of your last ten conversations, select a conversation to display all assigned and unassigned labels to the selected conversation, assign labels to the selected conversation, unassign a labels to the selected conversation.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row" id="plunker">
<div class="col-lg-12">
<h3>Stackblitz examples</h3>
<p>Short examples demonstrating one or more particular APIs. You can view the source, or fork your own stackblitz. A sandbox account is required to run the live examples.</p>
<table class="table table-condensed">
<thead>
<tr>
<th>Live Example</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="https://circuitsdk-conversation-export.stackblitz.io/" target="_blank">Export conversations to file</a></td>
<td>vuejs app to export all conversation messages to a file.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<h3>JS Bin examples</h3>
<p>Short examples demonstrating one or more particular APIs. You can view the source, or clone your own JS Bin using the link at the top right of the live example. A sandbox account is required to run the live examples. JS Bin examples use OAuth 2.0.</p>
<table class="table table-condensed">
<thead>
<tr>
<th>Live Example</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="https://output.jsbin.com/qiqewe" target="_blank">List conversations, threads and comments. Define injectors.</a></td>
<td>Retrieve 25 most recent conversations and display them in the left more list. When selecting a conversation, retrieve their 50 most recent threads and show them in the middle list. When selecting a thread, then show the 20 most recent comments in the right list. Defines conversationInjector and itemInjector.</td>
</tr>
<tr>
<td><a href="https://output.jsbin.com/waduvos" target="_blank">Moderate & EnableGuestAccess on conversation</a></td>
<td>Retrieve 10 most recent conversations, display them and allow functions on them such as disable guest access, moderate etc...</td>
</tr>
<tr>
<td><a href="https://output.jsbin.com/keyoleg" target="_blank">Get Conversation by a filter (e.g. label)</a></td>
<td>Retrieves the labels and upon selecting a label retrieves the converations using that label.</td>
</tr>
<tr>
<td><a href="https://output.jsbin.com/vejere" target="_blank">Moderation</a></td>
<td>Creates a conversation, turns on moderation and grants other user moderator rights.</td>
</tr>
<tr>
<td><a href="https://output.jsbin.com/dudalo" target="_blank">Update own user profile</a></td>
<td>Update firstname, lastname and email of local user.</td>
</tr>
<tr>
<td><a href="https://output.jsbin.com/kawuwul" target="_blank">Set presence</a></td>
<td>Set different presence states for local user.</td>
</tr>
<tr>
<td><a href="https://output.jsbin.com/xoluxuh" target="_blank">Search a favorited user using fuzzy search</a></td>
<td>Search a user by its name using fuse.js for fuzzy search.</td>
</tr>
<tr>
<td><a href="https://output.jsbin.com/pequyo" target="_blank">Get Favorites</a></td>
<td>Get all favorited conversation IDs, and then filter out the first 5 favorites of direct conversations.</td>
</tr>
<tr>
<td><a href="https://output.jsbin.com/fudexov" target="_blank">Send post with custom URL</a></td>
<td>Send a post with a link shown different from the actual URL. Use of option "removeMentionHtml".</td>
</tr>
<tr>
<td><a href="https://jsbin.com/posoko/" target="_blank">Direct HD video call & take snapshot</a></td>
<td>Start a direct call with another Circuit user. Toggle own video and ability to enable HD Video. Take a snapshot image of video with two options to download image.</td>
</tr>
<tr>
<td><a href="https://output.jsbin.com/masobut" target="_blank">Create conference bridge</a></td>
<td>Create a new conversation for a conference bridge, gets the conference details and waits for participants to join. Once other participants join the audio conference is established. No video in this example.</td>
</tr>
<tr>
<td><a href="https://output.jsbin.com/runifuq" target="_blank">Upgrade Direct Call to Conference</a></td>
<td>Start a direct call with another Circuit user, then add a 3rd user which automatically creates a group conversation and moves the call to the new conversation.</td>
</tr>
<tr>
<td><a href="https://output.jsbin.com/rasanum" target="_blank">Select media devices for call</a></td>
<td>Set the mic, camera, headset, etc for the call. Also supports changing the device during the call.</td>
</tr>
<tr>
<td><a href="https://output.jsbin.com/wuniwec" target="_blank">Switch front/back camera</a></td>
<td>Start a direct call with another Circuit user, then switch between different local video inputs (cameras). E.g. front/back on mobile device.</td>
</tr>
<tr>
<td><a href="https://output.jsbin.com/duxahi" target="_blank">Disable remote audio</a></td>
<td>Lookup active conferences, then join first one and disable the incoming audio stream.</td>
</tr>
<tr>
<td><a href="https://output.jsbin.com/haluwa" target="_blank">Send user to user message</a></td>
<td>Send a custom message to another user in a specific channel. Message is transparent to Circuit clients. For sending messaging to one of your other clients see API sendAppMessageToClient instead.</td>
</tr>
<tr>
<td><a href="https://output.jsbin.com/rujoduf" target="_blank">Incoming telephony call</a></td>
<td>Demonstrates the telephony APIs. Answer a telephony (ATC/UTC) call, move call to another device, pull call back, listen to telephony events.</td>
</tr>
<tr>
<td><a href="https://output.jsbin.com/medepa" target="_blank">Join a conference on a different device</a></td>
<td>Find started conferences in conversations user is a member of and list them. Then allow user to join one of the conferences on another of the user's devices.</td>
</tr>
<tr>
<td><a href="https://output.jsbin.com/lipido" target="_blank">Mute mic/speaker of webclient</a></td>
<td>Lookup active call on webclient, then mute mic and speaker for that call on that webclient.</td>
</tr>
<tr>
<td><a href="https://output.jsbin.com/dogise" target="_blank">Start a call from Circuit webclient</a></td>
<td>Start a direct call with a user initiated on one of your other devices. Also called Click-2-Call. Opens a new browser tab in case user is not logged on the another web-based client.</td>
</tr>
<tr>
<td><a href="https://output.jsbin.com/bitubit" target="_blank">Answer a call on different device</a></td>
<td>Answer a direct call on one of your other devices. Opens a new browser tab in case user is not logged on the another web-based client.</td>
</tr>
<tr>
<td><a href="https://output.jsbin.com/jeguyah" target="_blank">Whiteboard</a></td>
<td>Starts direct call and allows enabling the whiteboard. Use whiteboard background image and allow drawing SVG shapes.</td>
</tr>
<tr>
<td><a href="https://output.jsbin.com/pugirov" target="_blank">Custom OAuth 2.0 redirect_uri</a></td>
<td>Define a custom OAuth 2.0 redirect_uri for faster OAuth redirect. This will allow the OAuth popup to only load that redirect_uri page, and not the whole SDK.</td>
</tr>
<tr>
<td><a href="https://output.jsbin.com/zufovuf" target="_blank">Call Forwarding</a></td>
<td>Set and unset call forwarding on Circuit using the JS SDK.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<h3>GitHub examples</h3>
<p>The source code of the examples below are on <a href="https://github.com/circuit/circuit-sdk/tree/master/examples/js/" target="_blank">GitHub</a> and are hosted on <a href="https://rawgit.com/circuit/circuit-sdk/master/examples/js/index.html" target="_blank">rawgit</a>.</p>
<br>
</div>
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<a href="https://rawgit.com/circuit/circuit-sdk-app/master/index.html" target="_blank">
<img class="img-responsive" src="images/circuit-sdk-app.jpg" alt="">
</a>
</div>
<div class="panel-body">
<h5><i class="fa fa-fw fa-check"></i>Circuit-like web-app</h5>
<p>Circuit-like app built with vue.js and Circuit JS SDK. Showcases several different APIs. RTC APIs still to be added.</p>
<a href="https://rawgit.com/circuit/circuit-sdk-app/master/index.html" target="_blank" class="btn btn-default">Live example</a>
<a href="https://github.com/circuit/circuit-sdk-app" target="_blank" class="btn btn-default">Source</a>
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<a href="https://rawgit.com/circuit/circuit-sdk/master/examples/js/intro.html" target="_blank">
<img class="img-responsive" src="/images/intro.jpg" alt="">
</a>
</div>
<div class="panel-body">
<h5><i class="fa fa-fw fa-check"></i>Introduction example</h5>
<p>Logon using OAuth2, read most recent conversation. Defines injectors and shows conversation with extended injector attributes. Listens to various events.</p>
<a href="https://rawgit.com/circuit/circuit-sdk/master/examples/js/intro.html" target="_blank" class="btn btn-default">Live example</a>
<a href="https://github.com/circuit/circuit-sdk/blob/master/examples/js/intro.html" target="_blank" class="btn btn-default">Source</a>
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<a href="https://rawgit.com/circuit/circuit-sdk/master/examples/js/groupcall.html" target="_blank">
<img class="img-responsive" src="images/groupcall.jpg" alt="">
</a>
</div>
<div class="panel-body">
<h5><i class="fa fa-fw fa-check"></i>Group Call: video and screenshare</h5>
<p>This example shows how to start, join or leave a conference call. Also allows to toggle video or screenshare.
For screenshare the <a href="https://github.com/circuit/screenshare-chrome-extension" target="_blank">Circuit SDK Chrome Extension</a> is required.</p>
<a href="https://rawgit.com/circuit/circuit-sdk/master/examples/js/groupcall.html" target="_blank" class="btn btn-default">Live example</a>
<a href="https://github.com/circuit/circuit-sdk/blob/master/examples/js/groupcall.html" target="_blank" class="btn btn-default">Source</a>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<a href="https://rawgit.com/circuit/circuit-sdk/master/examples/js/messaging.html" target="_blank">
<img class="img-responsive" src="images/messaging.jpg" alt="">
</a>
</div>
<div class="panel-body">
<h5><i class="fa fa-fw fa-check"></i>Complete Messaging Examples (AngularJS)</h5>
<p>Shows complete messaging functionality. Allow to select a conversation to send a message to, upload files, or create a new conversation.</p>
<a href="https://rawgit.com/circuit/circuit-sdk/master/examples/js/messaging.html" target="_blank" class="btn btn-default">Live example</a>
<a href="https://github.com/circuit/circuit-sdk/blob/master/examples/js/messaging.html" target="_blank" class="btn btn-default">Source</a>
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<a href="https://rawgit.com/circuit/circuit-sdk/master/examples/js/directcall.html" target="_blank">
<img class="img-responsive" src="images/directcall.jpg" alt="">
</a>
</div>
<div class="panel-body">
<h5><i class="fa fa-fw fa-check"></i>Direct Call: audio and video</h5>
<p>This example shows how to start an audio/video direct call, or auto accept an incoming call.</p>
<a href="https://rawgit.com/circuit/circuit-sdk/master/examples/js/directcall.html" target="_blank" class="btn btn-default">Live example</a>
<a href="https://github.com/circuit/circuit-sdk/blob/master/examples/js/directcall.html" target="_blank" class="btn btn-default">Source</a>
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<a href="https://rawgit.com/circuit/circuit-sdk/master/examples/js/telephony.html" target="_blank">
<img class="img-responsive" src="images/telephony.jpg" alt="">
</a>
</div>
<div class="panel-body">
<h5><i class="fa fa-fw fa-check"></i>Telephony (PSTN) call</h5>
<p>Make outgoing phone calls to any regular telephone. Telephony Connector needs to be setup for your tenant.</p>
<a href="https://rawgit.com/circuit/circuit-sdk/master/examples/js/telephony.html" target="_blank" class="btn btn-default">Live example</a>
<a href="https://github.com/circuit/circuit-sdk/blob/master/examples/js/telephony.html" target="_blank" class="btn btn-default">Source</a>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<a href="https://rawgit.com/circuit/circuit-sdk/master/examples/js/dialout.html" target="_blank">
<img class="img-responsive" src="images/dialout.jpg" alt="">
</a>
</div>
<div class="panel-body">
<h5><i class="fa fa-fw fa-check"></i>Add participant to call</h5>
<p>Start a conference and dial out either a PSTN number, a Circuit user, or ring all conversation members.</p>
<a href="https://rawgit.com/circuit/circuit-sdk/master/examples/js/dialout.html" target="_blank" class="btn btn-default">Live example</a>
<a href="https://github.com/circuit/circuit-sdk/blob/master/examples/js/dialout.html" target="_blank" class="btn btn-default">Source</a>
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<a href="https://rawgit.com/circuit/circuit-sdk/master/examples/js/canvas.html" target="_blank">
<img class="img-responsive" src="images/canvas.jpg" alt="">
</a>
</div>
<div class="panel-body">
<h5><i class="fa fa-fw fa-check"></i>Share HTML5 Canvas</h5>
<p>This example shows a schematic in a HTML5 canvas and allows drawing on top of it and shares the combined image in the call.
The application can use the new <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/captureStream" target="_blank">HTMLCanvasElement.captureStream</a> API available in Chrome and Firefox to capture a stream from a canvas.
Note that Chrome has an issue with compression which causes WebRTC to reduce the resolution, or not even show the drawing.
Use <a href="https://www.mozilla.org/en-US/firefox/new/">FireFox</a> in the meantime.</p>
<a href="https://rawgit.com/circuit/circuit-sdk/master/examples/js/canvas.html" target="_blank" class="btn btn-default">Live example</a>
<a href="https://github.com/circuit/circuit-sdk/blob/master/examples/js/canvas.html" target="_blank" class="btn btn-default">Source</a>
</div>
</div>
</div>
<div class="col-md-4">
</div>
</div>
<!-- /.row -->
</div>
</div>
</div>
<!-- /#wrapper -->
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
<script>
$(function(){
$("#sidebar-wrapper").load("/sidebar.html");
});
</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','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-67318539-2', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>