General Category > Yate users hangout place

Custom API - NamedList

(1/4) > >>

ganapathi:
Hi,

As i am working on to develop custom API through cpp module.

Plan :

* Create Custom NamedList Variable through-out the call regardless of channel
* Store set of value through some module like CustomDriver,CustomChannel, miscellaneous module.May be each module would push some value into customnamed list variable
* Access through Custom module or copy parameters to new message to dispatch.
Because some module like chan.notify /call.answered doesn't have much information to process next message but at the same time need some message other than common value like billid,caller,called etc.

So in this cases in which class header( Whether YATE_API NamedList public section?) i need to define or initialize the named list . So that assign and access through out module.

NamedList Creation:


--- Code: ---NamedList* customdataList = new NamedList("");
--- End code ---


CustomDriver NamedList Assign:

--- Code: ---CustomDriver::msgExecute(Message& msg)
customdataList->addparam("customheader","customvalue");
--- End code ---


CustomChannelHandler Function :
Here have doubt on access the NamedList out of these two.

--- Code: ---customdataList->getValue("customheader");

or
NamedList* tmp = YOBJECT(NamedList,"customdataList");
tmp ->getValue("customheader");

or
NamedPointer* ss = new NamedPointer("customdataList");
NamedList* tmp = YOBJECT(NamedList,ss);
tmp ->getValue("customheader");


--- End code ---

I know i mis-understand some functionalities.  Second parameter of YOBJECT required pointer, but i don't know how to create pointer with specific string.I tried exact string, YSTRING but everything gives me error as well or no output.

marian:
Please describe more accurate what do you want to do and its purpose.

If you want to add a NamedList parameter to a Message keep in mind that only your module will handle it.

ganapathi:
As I want to store some value . For example need to assign  caller,called, queuename,source, greeting etc like some parameter value from CustomDriver in one of the module. And need to access these value from MessageHandler section from same module or from different module.

And I thought by using NamedList we can create one variable with list of value with key=>value basis.

Simply by adding custom handler on call.execute/call.preroute/route etc. then gather values and inserting to my variable then access it whenever I required by calling API function.

ganapathi:
QueueOutDriver::msgExecute()
{
..
Here I will catch source,greeting, caller,called value then emit chan.attach with source with notify parameter.
..
}
QueueOutHandler::received(Message& msg)
{
..
..
If Message is chan.notify then emit message with greeting. Also I need to emit some extra message need to dispatch. here I need to use some parameter value which I used on preroute/route. Or I will assign the value on my module whatever I want.
Here also I need to assign some value then access it on another Handler such as MailHandler::received.
}

marian:
You can use a NamedList to manage your own parameters but you won't be able to access them from other modules like regexroute.

Adding:
NamedList* nl = new NamedList("");
// ... fill 'nl' params
// Add it to a Message
msg.setParam(new NamedPointer("customdataList",nl));

Retrieve from Message:

NamedList* nl = YOBJECT(NamedList,msg.getParam("customdataList"));
if (nl) {
    // Handle it
}
else {
   // Parameter not present or not a NamedList object
}

Navigation

[0] Message Index

[#] Next page

Go to full version