pipobscure / NodeJS-AsteriskManager

NodeJS Asterisk Manager API
Other
248 stars 103 forks source link

VarSet variable name #43

Closed andreabianco closed 7 years ago

andreabianco commented 9 years ago

Hi! I'm listing on VarSet event but it's not clear how I can get the variable name: in the last variable is set as a json and the variable name is the key. Can you change with a string?

An example: variable: { sipcallid: '' }, value: 'xxxxxx'

jaromanda commented 7 years ago

It's not "a json", it's a plain ol' javascript object. if evt is the name of the event argument in your handler callback Object.keys(evt.variable)[0] should be the name of the variable - e.g.


ami.on('varset', function(evt) {
    console.log(Object.keys(evt.variable)[0], 'set to', evt.value);
});