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

@2people.it/asterisk-ami-adapter

v2.1.0

Published

Adapter to connect to ami interface

Downloads

606

Readme

@2people.it/asterisk-ami-adapter

release lint-and-test jekyll-gh-pages

It is a Node.js based solution for connecting to the Asterisk Manager Interface (AMI) via socket. AMI is a protocol for controlling, monitoring, and configuring an Asterisk PBX. This repository provides a flexible and efficient way to interact with the AMI, enabling developers to automate tasks, gather information about the system and users, and create custom applications for managing Asterisk.

To install the package, simply run the command

npm install @2people.it/asterisk-ami-adapter

or for powershell

npm install '@2people.it/asterisk-ami-adapter'

The main class of the repository, AsteriskAmiAdapter, extends from EventEmitter and provides a simple and straightforward way to connect to the AMI. The connect function establishes the connection, while the disconnect function terminates it. These functions allow you to quickly and easily manage your connection, giving you full control over your interactions with the AMI. Additionally, the sendAction function allows you to send AMI actions, allowing you to control and configure the system.

In addition to these functions, the class also emits several socket events that allow you to monitor the state of the connection and take appropriate actions in response to changes. The socket events are:

ami_connect // throw system socket event
ami_data // arise after incoming any message from ami
ami_login // arise after incoming successfull login message from ami
ami_socket_drain // throw  system socket event
ami_socket_error // throw system socket event
ami_socket_timeout // throw system socket event
ami_socket_end // throw system socket event
ami_socket_close // throw system socket event
ami_socket_unwritable // throw system socket event

With these events, you'll be able to handle various connection-related events, such as a successful login or a socket error.

One of the advantages of this repository is that it does not have any external dependencies. The adapter was written using only native Node.js modules, making it lightweight and easy to maintain. The repository is written in TypeScript, providing a strongly-typed and maintainable codebase. It uses modern programming techniques and patterns, making it easy to use and integrate into other projects. The adapter is built with scalability and performance in mind, making it a reliable and fast choice for projects of any size.

Whether you're looking to automate routine tasks, build custom applications, or integrate with other systems, asterisk-ami-adapter is the right tool for you. With its simple API and well-documented source code, you'll be able to get started quickly and take advantage of the full power of Asterisk AMI. So, check out the repository today, and take your Asterisk integration to the next level!"

Auto-generated documentation

https://2people-it.github.io/asterisk-ami-adapter

Features

  • Typescript
  • Zero dependiences

Getting started example

import { AsteriskAmiAdapter } from '@2people.it/asterisk-ami-adapter';

const adapter = new AsteriskAmiAdapter({
  encoding: "ascii",
  events: true,
  host: '127.0.0.1',
  password: "password",
  port: 5038,
  reconnect: true,
  reconnectDelay: 5000,
  username: "username",
});

adapter.connect();

adapter.on('ami_connect', () => {
  console.log('Connected to AMI');
});

adapter.on('ami_login', () => {
  console.log('Login successful');

  adapter.sendAction({
    Action: 'CoreShowChannels'
  });

  // if u need pass any variables, pass it to Array
  adapter.sendAction({
    Action: "Status",
    Variables: ["VAR_1", "VAR_2"],
  });
});

adapter.on('ami_data', (data) => {
  console.log(data);
});

adapter.on('ami_socket_error', (error) => {
  console.error(error);
});