[SR-Users] Dev documentation on implementing event_route events in custom module

Mojtaba mespio at gmail.com
Sat Jan 19 06:26:53 CET 2019


Yes, as YASIN  said, you could look register module. In the following i
paste a simple example of definition:
<function>
  int route_no;

    if(hi1_eventrb){
        route_no = route_get(&main_rt, hi1_eventrb);
        if (route_no == -1){
            LM_ERR("Failed to hi1 route block number of \"%s\", route_get()
function is failed\n", hi1_eventrb);
            return -1;
        }
        if (main_rt.rlist[route_no]==0){
            LM_WARN("The hi1 route block \"%s\" is empty, doesn't
exist\n",hi1_eventrb);
            return -1;
        }
        LM_DBG("hi1_eventrb is set successfully to %s route block\n",
hi1_eventrb);
        hi1_eventrb_no = route_no;
    }
    return 1
=====================================
And here sipmle example of calling event_route in your code:
int ret;
    struct run_act_ctx ra_ctx;
    struct sip_msg *msg;


    init_run_actions_ctx(&ra_ctx);

    if (run_actions(&ra_ctx, main_rt.rlist[hi1_eventrb_no], msg) < 0) {
        ret = -1;
                LM_DBG("Error while trying run script in route block\n");
        return ret;
    }
    return 1;


With Regards.Mojtaba

On Fri, Jan 18, 2019 at 11:07 PM YASIN CANER <caner_yaso at hotmail.com> wrote:

> Hello
>
> You can look registrar module that has usrloc:contact-expire
>
> Good luck
>
> Yasin Caner
>
> Mojtaba <mespio at gmail.com> şunları yazdı (18 Oca 2019 22:34):
>
> I'm gone away right now. I'll send for you as soon as
>
> On Fri, 18 Jan 2019, 22:34 Ivan Ribakov, <i.ribakov at zaleos.net> wrote:
>
>> Thanks for the suggestion. I thought about that, but TM module is not one
>> of the smallest. If there is a smaller, simpler model that uses events that
>> someone could recommend I could look into it. But in any case, I was
>> looking for something more documented to learn about all capabilities of
>> the events, not just the ones that might be used by some module.
>>
>> On 18 Jan 2019, at 17:43, Mojtaba <mespio at gmail.com> wrote:
>>
>> Hello Ivan,
>> Actually i haven't seen documentation but there is a good reference for
>> it, the impelemention of modules. You could look around them to find out.
>> It is very strightforwards.
>>
>>
>> On Fri, 18 Jan 2019, 18:57 Ivan Ribakov, <i.ribakov at zaleos.net> wrote:
>>
>>> Is there any documentation for module developers that lays out API for
>>> registering and triggering events from a custom Kamailio module (similar to
>>> https://kamailio.org/docs/modules/5.0.x/modules/tm.html#tm.event_routes)?
>>>
>>>
>>> I have been referring to
>>> https://www.kamailio.org/docs/kamailio-devel-guide/ up until now but it
>>> doesn’t seem to cover event_routes.
>>>
>>> Thanks in advance,
>>> Ivan
>>> _______________________________________________
>>> Kamailio (SER) - Users Mailing List
>>> sr-users at lists.kamailio.org
>>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>>
>> _______________________________________________
>> Kamailio (SER) - Users Mailing List
>> sr-users at lists.kamailio.org
>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>
>>
>> _______________________________________________
>> Kamailio (SER) - Users Mailing List
>> sr-users at lists.kamailio.org
>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>
> _______________________________________________
> Kamailio (SER) - Users Mailing List
> sr-users at lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>
> _______________________________________________
> Kamailio (SER) - Users Mailing List
> sr-users at lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>


-- 
--Mojtaba Esfandiari.S
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20190119/dd98152f/attachment.html>


More information about the sr-users mailing list