51
« on: October 23, 2018, 12:02:19 AM »
Some notes:
- Delete message after dispatch: memory leak
- Don't install a handler for each call in queue: install a module global one
- msg.getParam(YSTRING("id"))->c_str(): not a good idea if the 'id' parameter is missing this will lead to segfault
What is wrong:
You execute queue chan to tone. This will play ring in queue chan
When you attach queue chan to incoming call you the tone chan will be destroyed: not connected
To play ring you must use chan.attach to set tone source in desired call leg (in queue chan).
You may use the API (CallEndpoint::connect()) instead of call.connect message. Usual procedure of executing a call in a driver:
QueueInChannel* c = new QueueInChannel(dest,msg,false);
c->initChan();
DO_SETUP (attach tone source) ...
if (SETUP_OK) {
CallEndpoint* ch = YOBJECT(CallEndpoint,msg.userData());
if (ch && c->connect(ch,msg.getValue(YSTRING("reason")))) {
c->callConnect(msg);
msg.setParam("peerid",c->id());
msg.setParam("targetid",c->id());
c->deref();
return true;
}
}
CLEANUP ....
c->deref();
return false;