[asterisk-dev] Sending Channel Variables on events.
Chris Howard
chris at asteriasgi.com
Thu Feb 23 12:31:38 MST 2006
I need a way to receive channel variable data on certain events. For
example we are setting a contact_code on a channel in an AGI and we need
to be able to retrieve the contact_code via the AgentCalled manager
event. What I did was patch app_queue to use the
pbx_builtin_serialize_variables function to retreive all of the channel
variables for the channel being sent to the agent, replace the newlines
with a "|" and added it to the AgentCalled event. This works fine but
is there a better to accomplish this.
/* get channel variables *?
if(pbx_builtin_serialize_variables(qe->chan,vars,sizeof(vars)))
{
/* convert "/n" to "|" loop through pointer to char[] */
varPtr=vars;
while((varPtr = strchr(varPtr, '\n')))
*varPtr++ = '|';
ast_verbose(VERBOSE_PREFIX_3 "Channel Variables: %s\n", vars);
}
manager_event(EVENT_FLAG_AGENT, "AgentCalled",
"AgentCalled: %s\r\n"
"ChannelCalling: %s\r\n"
"CallerID: %s\r\n"
"CallerIDName: %s\r\n"
"Context: %s\r\n"
"Extension: %s\r\n"
"Priority: %d\r\n"
"ChanVars: %s\r\n",
tmp->interface, qe->chan->name,
tmp->chan->cid.cid_num ?
tmp->chan->cid.cid_num : "unknown",
tmp->chan->cid.cid_name ?
tmp->chan->cid.cid_name : "unknown",
qe->chan->context, qe->chan->exten,
qe->chan->priority,vars);
Christopher Howard
chris at asteriasgi.com
Asteria Solutions Group, Inc.
2904 Westcorp BLVD SW, Suite 203
Huntsville, AL, 35805
http://www.asteriasgi.com
Office: 256.705.0262
Main: 256.705.0277
TollFree: 877-ASGI-4-ME
Fax: 256.705.0280
Ask me about Asterisk!
More information about the asterisk-dev
mailing list