npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ami

v1.0.0

Published

Astersik Manager Interface

Downloads

13

Readme

ami NPM Version

Astersik Manager Interface

Install ami

This module requires node.js 14.0.0 or above and ES modules.

npm install ami

class AMISocket

import AMISocket from 'ami';

const ami = new AMISocket();

new AMISocket(options)

Construct a new AMI connection instance. Default options:

{
  connect: {
    host: 'localhost',
    port: 5038
  },
  credentials: {
    username: 'local',
    secret: 'local'
  },
  events: true
}

AMISocket#amiVersion

Version string provided by the Asterisk server, example 2.10.5. This property is undefined prior to receiving first line from connected socket.

AMISocket#connected

Boolean value if the socket is connected.

AMISocket#authenticated

Boolean value if the socket is authenticated.

async AMISocket#connect()

Connect to the AMI server for this instance. Promise is resolved once authentication is successful. Rejection occurs if connection or authentication fails.

This function resolves after queued packets are sent but before responses are received.

AMISocket#disconnect()

Disconnect from the AMI server. No attempt is made to wait for responses to requests that are in progress.

async AMISocket#send(object, options)

async AMISocket#getList(object, options)

object is the key/value pairs to send as an AMI request. This must contain an action key. A key can be specified multiple times by providing an array, for example:

ami.send({
  action: 'originate',
  // channel / app / etc
  variable: [
    'CHANVAR1=value',
    'CHANVAR2=value'
  ]
});

options.ignoreResponse can be set to true if you don't care about the result. In this case the promise resolves as soon as the request is written to the socket.

options.responseType controls the information provided when resolving:

  • response: resolves with a single object structured like the input object. This is default for AMISocket#send.
  • responses: resolves with an array of objects. This is default for AMISocket#getList.
  • responsePacket: resolves with a single AMIPacket instance.
  • responsePackets: resolves with an array of AMIPacket instances.

Keys of all responses are normalized to lowercase strings.

AMIPacket#asObject

This is the property which resolve requests that used responseType of response or responses.

AMIPacket#values

An ordered array of name/value pairs, for example:

[
  ['actionid', 'random-generated-id'],
  ['response', 'success']
]

This is only needed to deal with responses which violate the AMI specification. An example of this is the app_queue QueueRule response, see ASTERISK-27072.

AMIPacket#toString()

This is used internally to produce the raw data. It could also be used for debug output. Note that keys are already tranformed to lowercase.