Created
November 28, 2019 08:41
-
-
Save victor-shelepen/9f9fa78b6e2a5b1b3b0a27ed7551f654 to your computer and use it in GitHub Desktop.
Asterisk AMI Get bridge list example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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