I am having a problem with the handling of events triggered by a Local channel, which do not fire the listeners registered on its parent. The problem is a bit complex to explain, I will take an example:
First, I create a channel and register a listener on it:
var chan = ari.Channel();
chan.on('Dial', function(event) {
console.log('Dial received!');
});
Then, I do an originate on this channel, targeting a Local endpoint:
The dialplan located at exten@context is doing a Dial to a SIP peer, so I would expect to see Dial received in the console, but it is not happening. However, I can see Dial events coming from the websocket.
After looking more closely at the events and digging through the code, I figured out that this has something to do with the fact that when we originate a Local endpoint, Asterisk actually creates two Local channels connected by a virtual endpoint. And my listener is registered on the first Local channel, but it is the second Local channel which triggers the Dial events.
To be more precise, I register the events on a channel named 123456.789 (for example), but the Dial events are bound to the "child" channel 123456.789;2.
As there is no way to retrieve a reference to the child channel and thus register event handlers on it, I suggest that events bound to the child channel should trigger the listeners registered on the parent channel.
What do you think of that ? I did this modification on my own, I may submit it as a pull request if you will.
Hello,
I am having a problem with the handling of events triggered by a Local channel, which do not fire the listeners registered on its parent. The problem is a bit complex to explain, I will take an example:
The dialplan located at
exten@context
is doing a Dial to a SIP peer, so I would expect to seeDial received
in the console, but it is not happening. However, I can see Dial events coming from the websocket.After looking more closely at the events and digging through the code, I figured out that this has something to do with the fact that when we originate a Local endpoint, Asterisk actually creates two Local channels connected by a virtual endpoint. And my listener is registered on the first Local channel, but it is the second Local channel which triggers the Dial events.
To be more precise, I register the events on a channel named
123456.789
(for example), but the Dial events are bound to the "child" channel123456.789;2
.As there is no way to retrieve a reference to the child channel and thus register event handlers on it, I suggest that events bound to the child channel should trigger the listeners registered on the parent channel.
What do you think of that ? I did this modification on my own, I may submit it as a pull request if you will.