Author Topic: No Ringtone Custom Queue In Handle  (Read 21048 times)

ganapathi

  • Full Member
  • ***
  • Posts: 101
    • View Profile
No Ringtone Custom Queue In Handle
« on: October 22, 2018, 01:30:31 AM »
Hi

As am using custom handling for Queue Incoming module. But unable to playback the ringtone or custom music to the customer end.

Here you can find the code : https://paste.linux.community/view/7d30f87c

Also tried to attach once channel connected as well with mentioned below code.

Code: [Select]
Message* m = new Message("chan.attach");
m->copyParam(msg, "id");
m->addParam("source", "tone/ring");

But there is no ringtone on customer end.

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: No Ringtone Custom Queue In Handle
« Reply #1 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;

ganapathi

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: No Ringtone Custom Queue In Handle
« Reply #2 on: October 23, 2018, 12:51:41 AM »
Thanks. Now Understand.

And here are few doubt.
  • How do i call QueueInChannel destructor when Customer call hangup to emit chan.hangup and clean up the qin channel. Where am tracking chan.disconnected and dispatching the chan.hangup forcefully, eventhough qin channel not cleared.
  • You are trying to say Delete the Message after dispatch of QueueInChannel or every message such as call.execute/chan.connect etc. If then how do delete the message ?. i didn't find any procedure to delete message in source and perfect time to delete message.

Instead of msg.getParam(YSTRING("id"))->c_str(), msg.getValue("id") is fine. Or i need to validate if id is exist or not to proceed further to avoid segfault.
« Last Edit: October 23, 2018, 03:07:28 AM by ganapathi »

ganapathi

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: No Ringtone Custom Queue In Handle
« Reply #3 on: October 23, 2018, 03:03:18 PM »
- Don't install a handler for each call in queue: install a module global one

Using it only to pass the variable value where i am not sure how to pass variable and access it accordingly through-out the messages. And it would lead memory leak as well ?.
« Last Edit: October 23, 2018, 11:21:31 PM by ganapathi »

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: No Ringtone Custom Queue In Handle
« Reply #4 on: October 23, 2018, 11:42:45 PM »
I don't understand.
If you are speaking about matching call leg id you may always retrieve a channel in driver list. See Driver class documentation.
There is no memory leak in message handlers: the Engine will remove them on shutdown.
You may track them (keep a pointer) and remove from Engine when necessary.

ganapathi

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: No Ringtone Custom Queue In Handle
« Reply #5 on: October 23, 2018, 11:59:50 PM »
I meant to say am calling handler on every call only to pass some value like Queue name, partycallid etc. If i used global one then have no idea to get those value, where value is not available on every messages to utilize.

Is there any API functionalities available to push value and access it whenever required throughout the messages.

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: No Ringtone Custom Queue In Handle
« Reply #6 on: October 24, 2018, 12:04:44 AM »
Please specify your intention.
What is the working case?
What parameter are you talking about and where do you want to store them?
Remember: chan.connected is automatically sent by a Channel when connected to another one.

ganapathi

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: No Ringtone Custom Queue In Handle
« Reply #7 on: October 24, 2018, 12:25:59 AM »
As i need an billid, incoming channel ID(sig/1),queue_name and other some other value that's should necessary to validate some condition and append into another message.

For Ex :
Once call.answered message received from sip(sip/1) then need to emit chan.connect with sip/1 with sig/1. Where i can id for sip/1 but i need to get value of sig/1 through some variable. Like queue_name on chan.disconnected message need to emit new message to queue module.

And Also original billid which calls to queue module is not passing into Queue_Out Module, so need value to append to sip outleg.

Current Call.answered handler :
Quote
if (msg.getValue("id") == m_partycallid) {
            msg.setParam("reason", "pickup");
            return true;
}
else if (msg.getValue("targetid") == m_ourcallid)
{
   msg.setParam("targetid", m_partycallid);
   Message* mc = new Message("chan.connect");
   mc->copyParam(msg, "id");
   mc->addParam("targetid", m_partycallid);
   Engine::dispatch(mc);
   return true;
}
return false;


Value want to store :
  • billid
  • queue_name
  • partycallid
  • ..

Want to Store into Cache Memory/ Temp File Storage/ :
Store Like : JSON Object/Object List/Single Variable

Just for scenario ,It would be great if values are stored into ObjectList from Queue Module and access it on Queue_Outgoing Module.
« Last Edit: October 24, 2018, 12:33:59 AM by ganapathi »

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: No Ringtone Custom Queue In Handle
« Reply #8 on: October 24, 2018, 12:33:37 AM »
When you are handling (parking) an incoming call you known its id.
When you are executing an outbound call you have the outgoing call id in call.execute when message returns from dispatch.
Just remember them.
You may track them as needed.

You may use chan.locate to obtain channel pointer.
You may obtain billid using API. See Channel documentation.

ganapathi

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: No Ringtone Custom Queue In Handle
« Reply #9 on: October 24, 2018, 12:52:53 AM »
To get Billid with channel ID :
Code: [Select]
Message m("chan.locate");
m.addParam("id", m_partycallid);
if (Engine::dispatch(m)) {
Channel* c = new Channel(dest,m,true)
c->billid();
}

like this ?.


marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: No Ringtone Custom Queue In Handle
« Reply #10 on: October 24, 2018, 12:55:42 AM »
Please read https://docs.yate.ro/wiki/Chan.locate
Why do you think that locating a Channel implies building a new one?
You are searching for an item to check if it still exists and obtain some data from it

ganapathi

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: No Ringtone Custom Queue In Handle
« Reply #11 on: October 24, 2018, 03:07:34 AM »
Sorry. Got it now.

Here is the right one. Also tested.

Message l("chan.locate");
   l.addParam("id", msg.getValue("notify"));
   if (Engine::dispatch(l)) {
      Channel *dd = YOBJECT(Channel, l.userData());
      Output("Billid:%s", dd->billid().c_str());
   }


marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: No Ringtone Custom Queue In Handle
« Reply #12 on: October 24, 2018, 03:14:20 AM »
That's it!
For safety you should always check pointers (dd)

ganapathi

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: No Ringtone Custom Queue In Handle
« Reply #13 on: October 24, 2018, 05:43:01 AM »
Sure.

In My cases dataEndpoint are linked like below :

Customer Channel <--> Queue_In Channel
Queue_Out Channel <--> Operator Channel

In this case if customer Channel hangup then how to terminate queue_out Channel forcefully , because here Queue_Out won't disconnect until operator channel disconnected.

Dispatching a chan.hangup or Call Destructor(~OueueOutChannel()) of channel is right way?.

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: No Ringtone Custom Queue In Handle
« Reply #14 on: October 24, 2018, 06:00:53 AM »
For calling destructor see response on irc channel.
chan.hangup vever terminates a call leg: it's a notification sent by a call leg that protocol (external) call was terminated.
Use call.drop message to terminate a call leg.