[asterisk-dev] Help with AOC (Advice Of Charge) - price info on outbound calls

Matthew Jordan mjordan at digium.com
Wed Nov 22 07:28:17 CST 2017


On Wed, Nov 22, 2017 at 2:46 AM, Marin Odrljin <marin at maxcom.hr> wrote:
>
> Yes, that’s the way my app works all the time, there is no any AOC event sent to ARI. I was also expecting such events are sent to Stasis since I have found in ‘stasis.conf’ possibility to decline them:
>
>
>
> ; decline=aoc_s_type
>
> ; decline=aoc_d_type
>
> ; decline=aoc_e_type
>
>
>
> Other configuration files where AOC is mentioned are:
>
> -          ‘manager.conf’ for AMI which probably works, but I didn’t try it till now and would like to avoid it if possible
>
> -          ‘chan-dahdi.conf’ where I have enabled them
>
> -          ‘sip.conf’ for snom endpoints which I don’t need
>
>


Unfortunately, AOC events don't have a JSON representation and aren't
published to a Stasis topic that goes to ARI applications.

In aoc_publish_blob, you can see that we only publish the various AOC
events to the Manager topic (via ast_manager_get_topic):

msg = stasis_message_create(msg_type, aoc_event);
ao2_ref(aoc_event, -1);

stasis_publish(ast_manager_get_topic(), msg);

That pretty much limits AOC events to AMI today.

If you wanted this in ARI, you could pretty easily provide a patch to
do so. You'd need to:

* Change the topic that the messages are published to one that is
received by ARI. Assuming there is a channel involved, the easiest of
these is the channel topic. If there is no channel, you could publish
it to the generic 'all channels' topic. (Not all AOC events have a
channel, so you'd need to make sure it goes to some topic that makes
sense when that's the case.)

* Provide a JSON representation of the message. That means defining a
.to_json callback here which formats the message into JSON:

STASIS_MESSAGE_TYPE_DEFN(
aoc_s_type,
.to_ami = aoc_s_to_ami);

STASIS_MESSAGE_TYPE_DEFN(
aoc_d_type,
.to_ami = aoc_d_to_ami);

STASIS_MESSAGE_TYPE_DEFN(
aoc_e_type,
.to_ami = aoc_e_to_ami);

* Add the JSON representation of the message to the Swagger
specification (events.json) so that things get validated correctly.


For what it's worth, the data models wiki page shows the various
events that can be received:

https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+REST+Data+Models

-- 
Matthew Jordan
Digium, Inc. | CTO
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org



More information about the asterisk-dev mailing list