Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

update readme

  • Loading branch information...
commit 4bf94a738b9a645da47dd852705872e599ae16fb 1 parent 589e07e
@brianc authored
Showing with 15 additions and 4 deletions.
  1. +15 −4 README.md
View
19 README.md
@@ -9,37 +9,48 @@ node.js JavaScript client to communicate with an __A__sterisk __M__anager __I__n
`npm install ami`
## use
-
-### connect & login
```js
+//require
var Client = require('ami').Client;
var port = 5038; //default AMI port
var host = 'localhost';
var client = new Client();
+//connect to AMI server
client.connect(port, host, function onConnection(err) {
if(err) throw err;
- //create the action you want to send to asterisk
+ //create the login action (plain javascript object)
var login = {
action: 'login',
username: 'brian',
secret: 'shhh!'
}
- //send it and handle the response
+ //send the action to asterisk and handle the response
client.send(login, function(err, response) {
})
})
+//subscribe to all AMI messages (responses and events)
+client.on('message', function(msg) {
+ //message will be plain javascript object
+ //in the case of our login response message:
+ assert.equal(msg.actionID, '0');
+ assert.equal(msg.response, 'Success');
+ assert.equal(msg.message, 'Authentication accepted');
+})
+
```
## more info
Very much a work in progress. Would love contributions.
+[AMI documentation](http://www.voip-info.org/wiki/view/Asterisk+manager+API)
+
## more, more info
Fork & contribute! Open Source is awesome.
Please sign in to comment.
Something went wrong with that request. Please try again.