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

nami-raw

v0.6.3

Published

Minor fork of NAMI. It adds a raw event emitter and ability to subscribe to events on connect, sets keepalive. Original Description: An asterisk manager interface client, uses EventEmitter to communicate events, will allow you to send actions, and recei

Downloads

5

Readme

Introduction

For API and docs, check out the homepage at http://marcelog.github.com/Nami

You can also download the distribution and doc from the CI server, at: http://ci.marcelog.name:8080/view/NodeJS/

A very similar, PHP alternative, is available at http://marcelog.github.com/PAMI An Erlang port is available at https://github.com/marcelog/erlami

Nami by itself is just a library that allows your nodejs code to communicate to an Asterisk Manager Interface (AMI). However, it includes a full application useful to monitor an asterisk installation.

You will be able to login, receive asynchronous events, and send actions (also, asynchronously receiving the according response with their optional related events).

This is supported by the Nami class (er.. function) which inherits from EventEmitter, so your application is able to subscribe to the interesting nami events.

Requirements

  • Nodejs (Tested with 0.6.5)
  • log4js (For logging, tested with 0.3.9)

Events used in Nami

  • namiConnected: Emitted when nami could successfully connect and logged in to an AMI server.

  • namiConnection: Emitted for all connection related events. Listen to this generic event for the status of the socket connection.

  • namiConnection(EventName): Emitted for the status of the connection. States include: Connect, End, Error, Timeout, and Close. The Error event will emit right before the Close event and includes the error that was thrown. The Close event includes a boolean value (had_error) if an error was thrown.

  • namiEvent: Emitted for all events. Listen to this generic event if you want to catch any events.

  • namiEvent(EventName): These events are thrown based on the event name received. Let's say nami gets an event named "Dial", "VarSet", or "Hangup". This will emit the events: "namiEventDial", "namiEventVarSet", and "NamiEventHangup".

  • namiLoginIncorrect: Emitted when the login action fails (wrong password, etc).

  • namiInvalidPeer: Emitted if nami tried to connect to anything that did not salute like an AMI 1.1, 1.2, or 1.3.

Internal Nami events

  • namiRawMessage: Whenever a full message is received from the AMI (delimited by double crlf), this is emitted to invoke the decode routine. After namiRawMessage, the decodification routine runs to properly identify this message as a response, an event that belongs to a response, or an async event from server.

  • namiRawEvent: Emitted when the decodification routine classified the received message as an async event from server.

  • namiRawResponse: Emitted when the decodification routine classified the received message as a response to an action.

Installation

$ npm install log4js $ npm install nami

-or- Download it from this repo :)

Configuration

Nami expects a configuration object, very much like this: var namiConfig = { host: "amihost", port: 5038, username: "admin", secret: "secret" };

Quickstart

$ mkdir testnami $ npm install log4js $ npm install nami

var nami = new (require("nami").Nami)(namiConfig); nami.on('namiEvent', function (event) { }); nami.on('namiEventDial', function (event) { }); nami.on('namiEventVarSet', function (event) { }); nami.on('namiEventHangup', function (event) { }); process.on('SIGINT', function () { nami.close(); process.exit(); }); nami.on('namiConnected', function (event) { nami.send(new namiLib.Actions.CoreShowChannelsAction(), function(response){ logger.debug(' ---- Response: ' + util.inspect(response)); }); }); nami.open();

A Better example

See src/index.js for a better example (including how to reconnect when the current connection closes).

That's about it.

Multiple server support

See this gist for an example of how to connect to multiple asterisk boxes.

Supported Actions (Check the api for details)

Login Logoff Ping Hangup CoreShowChannels CoreStatus CoreSettings Status DahdiShowChannels ListCommands AbsoluteTimeout SipShowPeer SipShowRegistry SipQualifyPeer SipPeers AgentLogoff Agents AttendedTransfer ChangeMonitor Command CreateConfig DahdiDialOffHook DahdiDndOff DahdiDndOn DahdiHangup DahdiRestart DbDel DbDeltree DbGet DbPut ExtensionState GetConfig GetConfigJson GetVar SetVar JabberSend ListCategories PauseMonitor LocalOptimizeAway Reload PlayDtmf Park ParkedCalls Monitor ModuleCheck ModuleLoad ModuleReload ModuleUnload MailboxCount MailboxStatus VoicemailUsersList Originate Redirect UnpauseMonitor StopMonitor ShowDialPlan SendText Queues QueueUnpause QueuePause QueueSummary QueueStatus QueueRule QueueRemove QueueAdd QueueLog

Thanks to

  • Joshua Elson for his help in trying and debugging in loaded asterisk servers and testing with node 0.6.5 and newer npm versions
  • Jon Hoult for his help in testing with AMI 1.2