Comments (2)
I use this function to issue AMI commands:
function sendAsync(input) {
var ami = this;
return new Promise(function(fulfill, reject) {
var eventList = [];
var fetchingEvents = false;
ami.send(input, function(res) {
if (!fetchingEvents) {
if (res.Response === 'Error') {
reject(res.Message);
}
else if (res.EventList === 'start') {
fetchingEvents = true;
}
else if (res.Response === 'Success') {
if (res.Message !== 'Queue status will follow') {
fulfill(res);
} else {
fetchingEvents = true;
}
} else {
console.log(res);
}
}
else if (res.EventList === 'Complete') {
fulfill(eventList);
}
else if (res.Event) {
if (res.Event === 'QueueStatusComplete') {
fulfill(eventList);
} else if (res.Event !== 'QueueMember' && res.Event !== 'QueueParams') {
eventList.push(res);
}
} else {
console.log(res);
}
});
});
};
from ya-node-asterisk.
The only way to do it properly is to explicitly list all the available actions and use action-specific handlers, because even in Asterisk 13 AMI is still inconsistent. Some actions use event lists, while others don't.
from ya-node-asterisk.
Related Issues (9)
- a minor bug HOT 1
- Action responses HOT 1
- TS Error: Property 'eventlist' of type 'string | ActionResult[] | undefined' is not assignable to 'string' index type 'string | string[]'
- repeat each events when refresh client side (vuejs)
- Event Response limitation
- Get rid of setInterval in the connection object
- Handling socket errors
- ami.connect() as a Promise HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ya-node-asterisk.