Giter VIP home page Giter VIP logo

Comments (2)

avesus avatar avesus commented on August 17, 2024

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.

ipoddubny avatar ipoddubny commented on August 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.