Asterisk AMI Events Stream for NodeJS (ES2015)
This is a transform stream for AMI socket. This stream has a three custom events:
This library is a part of Asterisk's AMI Client library.
amiEvent
- fired when event was receive. Handler of this event receives AMI event object.amiResponse
- fired when response was receive. Handler of this event receives AMI response object.amiAction
- fired when action was receive. Handler of this event receives AMI action object.
If response from AMI not has structure like this:
<KEY>: <VALUE>CRLF
<KEY>: <VALUE>CRLF
...
<KEY>: <VALUE>CRLFx2
In above case, body of this response will be available in $content
property of response object.
Install
$ npm i asterisk-ami-events-stream
NodeJS versions
support >=4.0.0
Usage
const net = ;const amiUtils = ;const AmiEventsStream = ;const eventsStream = ; const amiSocket = net; amiSocket ; eventsStream ;
Examples
For examples, please, see tests ./test/*
.
Tests
Tests require Mocha.
mocha ./tests
or with npm
npm test
Test coverage with Istanbul
npm run coverage
License
Licensed under the MIT License