Skip to content

Instantly share code, notes, and snippets.

@victor-shelepen
Created November 28, 2019 08:41
Show Gist options
  • Save victor-shelepen/9f9fa78b6e2a5b1b3b0a27ed7551f654 to your computer and use it in GitHub Desktop.
Save victor-shelepen/9f9fa78b6e2a5b1b3b0a27ed7551f654 to your computer and use it in GitHub Desktop.
Asterisk AMI Get bridge list example.
async function getListBridge(config) {
const client = new AmiClient();
await client.connect(config.login, config.password, {host: 'localhost', port: 5038});
let bridgeList = [];
return new Promise((resolve, reject) => {
// Start.
client.on('resp_Bridge_List_A', data => {
bridgeList = [];
});
client.on('event', event => {
// Toggling.
if (event.Event === 'BridgeListComplete') {
resolve(bridgeList);
client.disconnect();
}
// Accumulation.
else if (event.Event == 'BridgeListItem') {
bridgeList.push(event);
}
});
// Action invoking.
client.action({
Action: 'BridgeList',
ActionID: 'Bridge_List_A'
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment