Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow events of a child Local channel to fire the listeners registered on its parent #40

Open
jaunis opened this issue Mar 31, 2016 · 0 comments

Comments

@jaunis
Copy link

jaunis commented Mar 31, 2016

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:

  • 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:
chan.originate({
    endpoint: 'Local/exten@context',
    app: 'myApp',
    appArgs: 'foo,bar'
});

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant