englercj / node-esl

FreeSWITCH ESL implementation for Node.js; implements the full Event Socket Library specified in: http://wiki.freeswitch.org/wiki/Esl
http://englercj.github.com/node-esl/
MIT License
171 stars 109 forks source link

Subscribing to registration events #19

Closed clintberry closed 11 years ago

clintberry commented 11 years ago

If I subscribe to all events on freeswitch, then do an on event for esl::event::** I see when I have devices register, but for the life of me I can't figure out how to only subscribe to registration events. I have tried subscribing to sofia::registration, then doing an on event for esl::event::custom::** but no luck. Is there a way to subscribe to sofia events via this library?

bryanpaluch commented 11 years ago

Did you try making CUSTOM all caps?

conn.on('esl::event::CUSTOM::*', function(evt){

});

clintberry commented 11 years ago

I believe I did, but let me check it one more time. When I subscribe, is sofia::registration the right thing so subscribe to?

englercj commented 11 years ago

Looks like you need both, according to the demo on the docs:

The event command are used to subscribe on events from FreeSWITCH. You may specify any number events on the same line, they should be separated with space. The events are listed in the Event List page. Examples:

  event plain ALL
  event plain CHANNEL_CREATE CHANNEL_DESTROY CUSTOM conference::maintenance sofia::register sofia::expire
  event xml ALL
  event json CHANNEL_ANSWER

Subsequent calls to 'event' won't override the previous event sets. Supposing, you've first registered for DTMF

Note that CUSTOM and sofia::register are used in that second line of the examples. I would register for both.

conn.subscribe('CUSTOM sofia::register', function() {
    conn.on('esl::event::CUSTOM::**', function(evt) {
        //something
    });
});
clintberry commented 11 years ago

ah ha, let me try that.

clintberry commented 11 years ago

Okay, I think I might have something wrong in my sofia config. I see debug logging in fs_cli but I don't get registration events at all in node-esl. I obviously have something up. I will close this ticket. Sorry for wasting your time on something that has nothing to do with your library.

englercj commented 11 years ago

Not a problem, glad to help!

clintberry commented 11 years ago

FYI, the namesapce esl::event::CUSTOM::** works once you have sofia logging on. Then I think it is up to you to parse which sub-event it is. Works great though.