Commit 25415466 authored by antirek's avatar antirek

up version to 0.1.0

change readme
parent f8aa80ac
...@@ -16,35 +16,47 @@ npm install ding-dong [--save] ...@@ -16,35 +16,47 @@ npm install ding-dong [--save]
Returns a new net.Server instance. The _listener_ will be called on a new agi connection with a single __Context__ object as described below. Returns a new net.Server instance. The _listener_ will be called on a new agi connection with a single __Context__ object as described below.
```js `````
var ding = require('ding-dong'); var ding = require('ding-dong');
ding.createServer(function(context) { ding.createServer(function(context) {
context.on('variables', function(vars) { context.onEvent('variables')
console.log('received new call from: ' + vars.agi_callerid + ' with uniqueid: ' + vars.agi_uniqueid); .then(function(vars) {
}); console.log('received new call from: ' + vars.agi_callerid + ' with uniqueid: ' + vars.agi_uniqueid);
})
.fail(console.log);
}).listen(3000); }).listen(3000);
```
`````
### Add to Asterisk extensions.conf ### Add to Asterisk extensions.conf
````` `````
[default] [default]
exten = > 1000,1,AGI(agi://localhost:3000) exten = > 1000,1,AGI(agi://localhost:3000)
````` `````
attention: using javascript promises
### new ding.Context(stream) ### new ding.Context(stream)
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. 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.
### context.exec(command, [args], [callback])
### context.exec(command, [args])
Dispatches the `EXEC` AGI command to asterisk with supplied command name and arguments. _callback_ is called with the result of the dispatch. Dispatches the `EXEC` AGI command to asterisk with supplied command name and arguments. _callback_ is called with the result of the dispatch.
```js ```js
context.exec('Dial', opt1, opt2, .., optN, function(err, res) { context.exec('Dial', opt1, opt2, .., optN)
.then(function(result)
//the channel call app Dial with options //the channel call app Dial with options
}); });
context.exec('RecieveFax', '/tmp/myfax.tif', function(err, res) { context.exec('RecieveFax', '/tmp/myfax.tif')
.then(function(result) {
//fax has been recieved by asterisk and written to /tmp/myfax.tif //fax has been recieved by asterisk and written to /tmp/myfax.tif
}); });
``` ```
...@@ -54,19 +66,20 @@ context.exec('RecieveFax', '/tmp/myfax.tif', function(err, res) { ...@@ -54,19 +66,20 @@ context.exec('RecieveFax', '/tmp/myfax.tif', function(err, res) {
Dispatches the 'HANGUP' AGI command to asterisk. Does __not__ close the sockets automatically. _callback_ is called with the result of the dispatch. Dispatches the 'HANGUP' AGI command to asterisk. Does __not__ close the sockets automatically. _callback_ is called with the result of the dispatch.
```js ```js
context.hangup(function(err, res) { context.hangup();
//the channel has now been hungup.
});
``` ```
Projects Use ding-dong
======== =============
[Voicer](http://github.com/antirek/voicer) - AGI yandex voice recognizer for Asterisk [voicer](http://github.com/antirek/voicer) - AGI yandex voice recognizer for Asterisk
[agi-number-archer](http://github.com/antirek/agi-number-archer) - AGI server for find region code of phone number (Russia) [agi-number-archer](http://github.com/antirek/agi-number-archer) - AGI server for find region code of phone number (Russia)
[lcr-finder](http://github.com/antirek/voicer) - least cost router for Asterisk
## Links ## Links
[Asterisk AGI](https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+AGI+Commands) [Asterisk AGI](https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+AGI+Commands)
...@@ -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.0.9", "version": "0.1.0",
"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