Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ami

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ami

Astersik Manager Interface

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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.

FAQs

Package last updated on 01 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc