Commit 3addc92d authored by antirek's avatar antirek

up to version 0.1.1

parent 9a1cf963
...@@ -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])
......
var AGIServer = require('./lib/index'); var AGIServer = require('./../lib/index');
var handler = function (context) { var handler = function (context) {
context.onEvent('variables') context.onEvent('variables')
......
...@@ -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"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment