Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
alvagi
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
alvagi
Commits
3addc92d
Commit
3addc92d
authored
Jun 11, 2015
by
antirek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
up to version 0.1.1
parent
9a1cf963
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
17 deletions
+26
-17
README.md
README.md
+24
-15
app.js
example/app.js
+1
-1
package.json
package.json
+1
-1
No files found.
README.md
View file @
3addc92d
...
@@ -20,24 +20,32 @@ Use ding-dong
...
@@ -20,24 +20,32 @@ Use ding-dong
```
```
npm install ding-dong [--save]
npm install ding-dong [--save]
```
```
## API
##
# ding.createServer([listener])
##
Usage
Returns a new net.Server instance. The _listener_ will be called on a new agi connection with a single __Context__ object as described below.
### Write app.js and run it
```
``
```
``
var
ding
= require('ding-dong');
var
AGIServer
= require('ding-dong');
ding.createServer(function
(context) {
var handler = function
(context) {
context.onEvent('variables')
context.onEvent('variables')
.then(function
(vars) {
.then(function
(vars) {
console.log('received new call from: ' + vars.agi_callerid + ' with uniqueid: ' + vars.agi_uniqueid
);
return context.streamFile('beep'
);
})
})
.fail(console.log);
.then(function (result) {
}).listen(3000);
return context.setVariable('RECOGNITION_RESULT', 'I\'m your father, Luc');
})
.then(function (result) {
return context.end();
});
};
var agi = new AGIServer(handler);
agi.start(3000);
```
``
```
``
...
@@ -48,13 +56,14 @@ ding.createServer(function(context) {
...
@@ -48,13 +56,14 @@ ding.createServer(function(context) {
exten = > 1000,1,AGI(agi://localhost:3000)
exten = > 1000,1,AGI(agi://localhost:3000)
`````
`````
### And call to 1000 and view asterisk output.
attention: using javascript promises
##
# new ding.Context(stream)
##
API
Constructor to create a new instance of a context. Supply a readable and writable stream to the constructor. Commonly _stream_ will be a `net.Socket` instance.
attention: using javascript promises
### context.exec(command, [args])
### context.exec(command, [args])
...
...
app.js
→
example/
app.js
View file @
3addc92d
var
AGIServer
=
require
(
'
./lib/index
'
);
var
AGIServer
=
require
(
'
./
../
lib/index
'
);
var
handler
=
function
(
context
)
{
var
handler
=
function
(
context
)
{
context
.
onEvent
(
'
variables
'
)
context
.
onEvent
(
'
variables
'
)
...
...
package.json
View file @
3addc92d
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
"author"
:
"Sergey Dmitriev <serge.dmitriev@gmail.com>"
,
"author"
:
"Sergey Dmitriev <serge.dmitriev@gmail.com>"
,
"name"
:
"ding-dong"
,
"name"
:
"ding-dong"
,
"description"
:
"Write AGI-server quickly! (AGI - Asterisk Gateway Interface)"
,
"description"
:
"Write AGI-server quickly! (AGI - Asterisk Gateway Interface)"
,
"version"
:
"0.1.
0
"
,
"version"
:
"0.1.
1
"
,
"repository"
:
{
"repository"
:
{
"type"
:
"git"
,
"type"
:
"git"
,
"url"
:
"git://github.com/antirek/ding-dong.git"
"url"
:
"git://github.com/antirek/ding-dong.git"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment