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
170 stars 111 forks source link

CHANNEL_EXECUTE_COMPLETE events interfere with each other #23

Closed kbdfck closed 10 years ago

kbdfck commented 10 years ago

When launching something via "execute", CHANNEL_EXECUTE_COMPLETE events from previous "execute" calls are getting in execute callback, effectively destroying program flow by launching callbacks before applications they was targeted to are actually finished.

What is better way to handle this? Maintaining execute queue in each program seems to be waste of time, maybe it worth creating execute callback queue in connection.js like you do for api calls?

englercj commented 10 years ago

Executes are tracked via UUID, if you are using an inbound socket (you connecting to freeswitch) you can either pass a UUID to .execute to be used or it creates one for you via create_uuid.

Otherwise, if you are using an outbound socket (freeswitch connecting to you) the UUID of your socket is used. Are you getting this issue on outbound sockets, or inbound sockets?

kbdfck commented 10 years ago

I also commented here: https://github.com/englercj/node-esl/pull/24

The problem is not UUID tracking, but rather EXECUTE_COMPLETE event ordering. We use outbound socket, and now code runs callback at any 'CHANNEL_EXECUTE_COMPLETE' event on channel with our UUID, but this is not correct, since there may be previous calls to 'execute' without callbacks, for example.

englercj commented 10 years ago

Following the thread you mentioned I pushed a fix that will track execute callbacks based on a generated UUID that is passed along (and hopefully back) with the event. This feature is in v1.1.0 and later, please let me know if you have issues with it.