Commit 302e6943 authored by sergey's avatar sergey

up version

change readme
parent 71085fbc
# node-agi # ding-dong
Client for asterisk AGI protocol. Parses incomming messages into events. Dispatches AGI commands and their responses from asterisk. Most commonly used as a low level client for a fAGI server. Create AGI server with ding-dong. Use with Asterisk for fast telephony apps. (Fork of node-agi)[http://github.com/brianc/node-agi]
## note: still a work in progress
## install ## install
``` ```
npm install agi npm install ding-dong [--save]
``` ```
## API ## API
### agi.createServer([listener]) ### ding.createServer([listener])
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 ```js
require('agi').createServer(function(context) { var ding = require('ding-dong');
ding.createServer(function(context) {
//context is a new instance of agi.Context for each new agi session //context is a new instance of agi.Context for each new agi session
//immedately after asterisk connects to the node process //immedately after asterisk connects to the node process
context.on('variables', function(vars) { context.on('variables', function(vars) {
...@@ -24,8 +24,14 @@ require('agi').createServer(function(context) { ...@@ -24,8 +24,14 @@ require('agi').createServer(function(context) {
}); });
}).listen(3000); }).listen(3000);
``` ```
### Add to Asterisk extensions.conf
`````
[default]
exten = > 1000,1,AGI(agi://localhost:3000)
`````
### new agi.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.
...@@ -34,8 +40,8 @@ Constructor to create a new instance of a context. Supply a readable and writab ...@@ -34,8 +40,8 @@ Constructor to create a new instance of a context. Supply a readable and writab
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('ANSWER', function(err, res) { context.exec('Dial', opt1, opt2, .., optN, function(err, res) {
//the channel is now answered //the channel call app Dial with options
}); });
context.exec('RecieveFax', '/tmp/myfax.tif', function(err, res) { context.exec('RecieveFax', '/tmp/myfax.tif', function(err, res) {
...@@ -43,7 +49,7 @@ context.exec('RecieveFax', '/tmp/myfax.tif', function(err, res) { ...@@ -43,7 +49,7 @@ context.exec('RecieveFax', '/tmp/myfax.tif', function(err, res) {
}); });
``` ```
### context.hangup([callbac]) ### context.hangup([callback])
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.
...@@ -52,3 +58,12 @@ context.hangup(function(err, res) { ...@@ -52,3 +58,12 @@ context.hangup(function(err, res) {
//the channel has now been hungup. //the channel has now been hungup.
}); });
``` ```
## Projects
(Voicer)[http://github.com/antirek/voicer] - AGI yandex voice recognizer for Asterisk
## Links
(Asterisk AGI)[https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+AGI+Commands]
\ No newline at end of file
...@@ -157,4 +157,4 @@ Context.prototype.end = function() { ...@@ -157,4 +157,4 @@ Context.prototype.end = function() {
this.stream.end(); this.stream.end();
}; };
module.exports = Context; module.exports = Context;
\ No newline at end of file
...@@ -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": "AGI (Asterisk Gateway Interface) for writing dialplan scripts", "description": "AGI (Asterisk Gateway Interface) for writing dialplan scripts",
"version": "0.0.4", "version": "0.0.5",
"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