forked from asterisk/asterisk_rest_libraries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_asteriskjs.html
executable file
·120 lines (112 loc) · 3.23 KB
/
test_asteriskjs.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
<!DOCTYPE html>
<html>
<!--
- Copyright (C) 2013 Digium, Inc.
- All Rights Reserved.
- @Package: test_asteriskjs.html
- @Authors: Erin Spiceland <[email protected]>
-
- See http://www.asterisk.org for more information about
- the Asterisk project. Please do not directly contact
- any of the maintainers of this project for assistance;
- the project provides a web site, mailing lists and IRC
- channels for your use.
-
- This program is free software, distributed under the terms
- detailed in the the LICENSE file at the top of the source tree.
-
-->
<head>
<title>Test AsteriskJs</title>
<script type='text/javascript'
src='javascript/lib/asteriskjs.js'>
</script>
<script type='text/javascript'
src='javascript/lib/asterisk.js'>
</script>
<script type='text/javascript'
src='javascript/lib/bridge.js'>
</script>
<script type='text/javascript'
src='javascript/lib/channel.js'>
</script>
<script type='text/javascript'
src='javascript/lib/endpoint.js'>
</script>
<script type='text/javascript'
src='javascript/lib/recording.js'>
</script>
<script type='text/javascript'
src='javascript/lib/asterisk_rest_api.js'>
</script>
</head>
<body>
<div id='content'></div>
<script type='text/javascript'>
var content = document.getElementById('content');
var runTests = function(ast) {
console.log(ast);
ast.getAsteriskInfo();
ast.getEndpoints();
ast.getChannels();
ast.getBridges();
ast.getRecordings();
ast.createChannel({'tech': 'dummy_params'});
ast.createBridge({'tech': 'dummy_params'});
var endpoints = [new AsteriskJs.Endpoint({'api': ast.api})];
var channels = [new AsteriskJs.Channel({'api': ast.api})];
var bridges = [new AsteriskJs.Bridge({'api': ast.api})];
var recordings = [new AsteriskJs.Recording({'api': ast.api})];
for (var i = 0; i < endpoints.length; i++) {
var endpoint = endpoints[i];
content.innerHTML += "got endpoint with id " + endpoint.getId()
+ "<br />\n";
}
for (var i = 0; i < channels.length; i++) {
var channel = channels[i];
content.innerHTML += "got channel with id " + channel.getId()
+ "<br />\n";
channel.deleteChannel();
channel.rejectChannel();
channel.answerChannel();
channel.muteChannel();
channel.unmuteChannel();
channel.recordChannel('rec name');
channel.dial();
channel.continueInDialplan();
channel.originate();
}
chan = new AsteriskJs.Channel({'api': ast.api});
for (var i = 0; i < bridges.length; i++) {
var bridge = bridges[i];
bridge.getId();
bridge.newBridge();
bridge.deleteBridge();
bridge.addChannelToBridge(chan.getId());
bridge.removeChannelFromBridge(chan.getId());
bridge.recordBridge('rec name');
}
for (var i = 0; i < recordings.length; i++) {
var recording = recordings[i];
recording.getId();
recording.deleteRecording();
recording.stopRecording();
recording.pauseRecording();
recording.unpauseRecording();
recording.muteRecording();
recording.unmuteRecording();
}
};
window.onload = function() {
var ast = new AsteriskJs().init({
'api_url': 'http://10.24.67.73:8088/stasis',
'responseHandler' : function(response, data) {
content.innerHTML += data.uri + ' returns ' + response.status + ": "
+ response.responseText + ' <br />';
}
});
runTests(ast);
};
</script>
</body>
</html>